Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Lazada link

from bs4 import BeautifulSoup, SoupStrainer
import requests
import json

url = "https://www.lazada.com.my/oldtown-white-coffee/?langFlag=en&q=All-Products&from=wangpu&pageTypeId=2"

page = requests.get(url)    
data = page.text
soup = BeautifulSoup(data)


scripts = soup.find_all('script')

jsonObj = None
for script in scripts:
    if 'window.pageData=' in script.text:
        jsonStr = script.text

        jsonStr = jsonStr.split("window.pageData=")[1]
        jsonObj = json.loads(jsonStr)


products = jsonObj['mods']['listItems']

for item in products:
    print (item['productUrl'])
Comment

PREVIOUS NEXT
Code Example
Python :: djago get settings 
Python :: factorial python 
Python :: struct trong Python 
Python :: EXCEL , EXTRAER DELIMITADOR 
Python :: append to a list without intializing 
Python :: special characters in python 
Python :: get_multiple_items_from_list 
Python :: torch remove part of array 
Python :: le %s 
Python :: schema json in oython 
Python :: group by month and year 
Python :: str vs rper in python 
Python :: This code is supposed to display "2 "2 + 2 = 4"" on the screen, but there is an error. Find the error in the code and fix it, so that the output is correct. 
Python :: how to make a new df from old 
Python :: load xgb 
Python :: pyttsx3 interrupting an utterance 
Python :: Python Anagram Using sorted() function 
Python :: Flatten List in Python Using Shallow Flattening 
Python :: how to change multiple index in list in python 
Python :: write console output in same place 
Python :: python replace every space, dash and parentheses into underscore 
Python :: python multi dimensional dict 
Python :: godot ternary 
Python :: Python NumPy atleast_2d Function Example 
Python :: conmbination in python 
Python :: Python NumPy asarray_chkfinite Function Example Raises Value Error 
Python :: configure socketio static file python specific content type 
Python :: python __truediv__ 
Python :: python service linux 
Python :: Convertion of an array into binary using NumPy binary_repr 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =