Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find() got always None on JS rendered website #564

Open
EvansPM opened this issue Dec 25, 2023 · 0 comments
Open

find() got always None on JS rendered website #564

EvansPM opened this issue Dec 25, 2023 · 0 comments

Comments

@EvansPM
Copy link

EvansPM commented Dec 25, 2023

I'm trying to use this package on a website rendered in JS, but using the method render() do not change nothing, still not able to get any elements.

Platform:

Ubuntu 20.04
Python: 3.6.15

Code:

from requests_html import HTMLSession
session = HTMLSession()

session.headers['User-Agent'] = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0"
session.headers['Accept'] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
session.headers['Accept-Language'] = "en-US,en;q=0.5"
session.headers['Connection'] = "keep-alive"
session.headers['Upgrade-Insecure-Requests'] = "1"

url = "https://hastinfo.calgarytransit.com/HastinfoMVCWeb/TravelPlans?TimeType=SpecifiedDepartureTime&Date=2023-12-24&Time=22%3A20&OriginType=Stop&OriginIdentifier=5067&DestinationType=Landmark&DestinationIdentifier=308"
r = session.get(url)

r.html.render()

print(r.status_code)


# select element 
#start = r.html.xpath('//div[@class="TravelPlanSummaryStartTime"]')
start = r.html.find('#TravelPlansSummaries', first=True)
print(start)

Output:

200
None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant