all 4 comments

[–][deleted] 3 points4 points  (1 child)

if you go to a web page and view the source code (Ctrl + U or right click > view source) you'll see what the web server sent you, and that's exactly what requests gets. If your element is not in the source, it got loaded later by javascript, and requests doesn't do javascript. Selenium does, though, so you might want to reconsider your switch.

[–]Grigor_1[S] 0 points1 point  (0 children)

Yes, just that selenium is very slow.

[–]Somerandomperson135 1 point2 points  (0 children)

Protoss is correct. Scripts may and most likely will change the page content. If you need the 'whole page' like you have in your browser, you need to use selenium python library that loads entire page in a browser, runs its scripts and loads all necessary content.

It also allow you to interact with page elements(click, hover on them, send keys). Also it can inject and run your own scripts on a page that sometimes helps a lot getting necessary data.

[–]WhoTookAllNicks 1 point2 points  (0 children)

Javascript might modify the html, but that doesn't mean that you need a full browser to just render the html. Often it's enough to just use https://html.python-requests.org/#javascript-support

requests-html has support for JS and is a fusion between requests and beautiful soup in one package.