Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

Scrape Data from AJAX URL (Python)

I'm trying to learn more about web scraping, but I stumbled upon a problem while trying to scrape data from the following URL:

https://www.encuentra24.com/guatemala-es/ajax/bienes-raices-venta-de-propiedades-casas?&page=2&list=category

If instead of an AJAX the URL contained the information in a JSON, I could easily scrape the information with the following code:

# Assign URL to variable: url
url = 'https://www.encuentra24.com/guatemala-es/ajax/bienes-raices-venta-de-propiedades-casas?&page=2&list=category'

# Package the request, send the request and catch the response: r
r = requests.get(url)

# Decode the JSON data into a dictionary: json_data
json_data = r.json()

# Extract data from the Json file
json_data_2 = json_data['listing']

#normalize json data into a dataframe
df = json_normalize(json_data_2)
df.head()

But, since it seems to be AJAX, I'm completely lost.

Any comments or help will be highly appreciated.

Thank you!

question from:https://stackoverflow.com/questions/65836815/scrape-data-from-ajax-url-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...