Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests from bs4
- import BeautifulSoup as soup
- import json
- 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'
- cookies = {
- "Hm_lpvt_7cd4710f721b473263eed1f0840391b4": "1548175412",
- "Hm_lvt_7cd4710f721b473263eed1f0840391b4": "1548140525",
- "x5sec":"7b22617365727665722d6c617a6164613b32223a223832333339343739626466613939303562613535386138333266383365326132434c4b516e65494645495474764a322b706f6d6f6941453d227d", }
- ret = requests.get(my_url, cookies=cookies)
- print("New Super Mario Bros" in ret.text) # True
- page_soup = soup(ret.text, 'html.parser')
- data = page_soup.findAll('script', {'type':'application/ld+json'})
- [
- <scripttype="application/ld+json">{
- "@context": "https://schema.org",
- "@type": "BreadcrumbList",
- "itemListElement": [
- {
- "item": {
- "name": "Home",
- "@id": "https://www.lazada.sg/"
- },
- "@type": "ListItem",
- "position": "1"
- }
- ]
- }</script>,
- <scripttype="application/ld+json">{
- "@context": "https://schema.org",
- "@type": "ItemList",
- "itemListElement": [
- {
- "offers": {
- "priceCurrency": "SGD",
- "@type": "Offer",
- "price": "71.00",
- "availability": "https://schema.org/InStock"
- },
- "image": "https://sg-test-11.slatic.net/p/670a73a9613c36b2bb01555ab4092ba2.jpg",
- "@type": "Product",
- "name": "Switch: Super Mario Party [Available in Stock! Immediate Shipping]",
- "url": "https://www.lazada.sg/products/switch-super-mario-party-available-in-stock-immediate-shipping-i278269540-s429667097.html?search=1"
- },
- ...
Add Comment
Please, Sign In to add comment