SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests from bs4
  2. import BeautifulSoup as soup
  3. import json
  4.  
  5. my_url = 'https://www.lazada.sg/catalog/?spm=a2o42.home.search.1.488d46b5mJGzEu&q=switch%20games&_keyori=ss&from=search_history&sugg=switch%20games_0_1'  
  6.  
  7. cookies = {
  8.     "Hm_lpvt_7cd4710f721b473263eed1f0840391b4": "1548175412",
  9.     "Hm_lvt_7cd4710f721b473263eed1f0840391b4": "1548140525",
  10.     "x5sec":"7b22617365727665722d6c617a6164613b32223a223832333339343739626466613939303562613535386138333266383365326132434c4b516e65494645495474764a322b706f6d6f6941453d227d", }
  11.  
  12. ret = requests.get(my_url, cookies=cookies)
  13. print("New Super Mario Bros" in ret.text) # True
  14.  
  15. page_soup = soup(ret.text, 'html.parser')
  16. data = page_soup.findAll('script', {'type':'application/ld+json'})
  17.    
  18. [
  19.   <scripttype="application/ld+json">{
  20.     "@context": "https://schema.org",
  21.     "@type": "BreadcrumbList",
  22.     "itemListElement": [
  23.       {
  24.         "item": {
  25.           "name": "Home",
  26.           "@id": "https://www.lazada.sg/"
  27.         },
  28.         "@type": "ListItem",
  29.         "position": "1"
  30.       }
  31.     ]
  32.   }</script>,
  33.   <scripttype="application/ld+json">{
  34.     "@context": "https://schema.org",
  35.     "@type": "ItemList",
  36.     "itemListElement": [
  37.       {
  38.         "offers": {
  39.           "priceCurrency": "SGD",
  40.           "@type": "Offer",
  41.           "price": "71.00",
  42.           "availability": "https://schema.org/InStock"
  43.         },
  44.         "image": "https://sg-test-11.slatic.net/p/670a73a9613c36b2bb01555ab4092ba2.jpg",
  45.         "@type": "Product",
  46.         "name": "Switch: Super Mario Party [Available in Stock! Immediate Shipping]",
  47.         "url": "https://www.lazada.sg/products/switch-super-mario-party-available-in-stock-immediate-shipping-i278269540-s429667097.html?search=1"
  48.       },
  49.       ...
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top