[Tutor] Webbrowser's capabilities to do more than just open up a webpage

Jim jf_byrnes at comcast.net
Mon Aug 31 16:11:28 EDT 2020


On 8/31/20 1:08 PM, Stephen M Smith wrote:
> I am having trouble with various websites detecting the usage of python,
> selenium and chrome and rejecting my request to make reservations
> automatically. I am not scraping or in any way violating information that
> anyone could or would consider private or proprietary. I have read through
> all of the questions i can find (
> <https://stackoverflow.com/questions/58873022/how-to-make-selenium-script-un
> detectable-using-geckodriver-and-firefox-through-p> How to make Selenium
> script undetectable using GeckoDriver and Firefox through Python? - to cite
> one) and have tried most if not all of the recommendations. I continue to
> experiment with combinations of what is suggested, but have not found the
> answer yet.
> 
> However, it occurs to me that using the python webbrowser module directly
> would allow me to eliminate the middleman (selenium) and keep my usage
> clean. (Using wireshark i can see that the header sent with webbrowser
> appears to be exactly the same as the header sent when i invoke chrome
> manually, with selenium it is different.) However, webbrowser does not seem
> to have the ability to fill in forms, 'press' buttons and locate and
> interact with various elements. In other words, I need to be able to
> manually create the click, switch_to_frame, xpath_search,
> find_element_by_class_name, etc. functions provided by selenium. I first
> hoped that these capabilities would be available in webbrowser, but that
> seems to be wrong. Then i thought that perhaps i could look through the
> selenium code and learn how those capabilities were provided and
> borrow/copy, but that has proven to be difficult. Finally i thought perhaps
> i could use webbrowser to get started, and then introduce selenium to query
> the site opened natively (with webbrowser), but i can't figure out if that
> is possible and am not sure that will work.
> 
> I am hoping someone out there more knowledgeable than me can point me in the
> right direction. I know i may be biting off a lot, but i am basically a
> python hobbyist and am enjoying the learning process.
> 
> Thanks as always for any and all help provided.
> 
>   
> 

You might want to look at pyppeteer - 
https://pypi.org/project/pyppeteer/. I have never needed to use it, but 
if I had problems with selenium I would give it a try.

pyautogui may be an option. You can give it screen coordinates and it 
will click buttons and type in text. This is a little fragile if the 
elements on the screen  don't always appear where you think they will

Sometimes you can move around a web page using the keyboard. pyautogui 
can issue keyboard commands like <tab> <right> etc.

Regards,  Jim




More information about the Tutor mailing list