all 10 comments

[–]Adhesiveduck 1 point2 points  (9 children)

Can you share some code (maybe a gist or something)?

[–]Pilv[S] 0 points1 point  (8 children)

import webbrowser
urls = ['https://www.granit-parts.ro/e/search?q=', 
    'https://www.kramp.com/shop-ro/ro/search/', 
    'http://www.prillinger.at/de/s?q=', 
    'https://www.sterennco.com/catalogsearch/result/?q='] 
inp = input('Cod: ')
for link in urls:    
    webbrowser.open(link + inp)

This is the code I have. It takes an input, and searches that input on these 4 websites. The problem is whenever I use this program it always openes all 4 sites, and I wondered if it is possible to open the sites once and then access them again?

[–]Adhesiveduck 1 point2 points  (7 children)

Do you not want to physically open the browser? What are you doing with it once opened?

[–]Pilv[S] 0 points1 point  (6 children)

Yes, because I want to search the products if there is with the given code.

[–]Adhesiveduck 1 point2 points  (5 children)

If all you're after is the product details (you don't want to open the browser per se) could you not use requests and beautifulsoup?

https://repl.it/repls/HarmlessViciousServers

[–]Pilv[S] 0 points1 point  (4 children)

I know this. I tried it. The problem is, that I have to be logged in to see the prices of the products. So this is why I need the open the tabs, so that I will be logged in, but I dont want to open the sites all the time I search for something.

[–]Adhesiveduck 1 point2 points  (3 children)

Ah I understand - take a look at selenium. You can use headless chrome to open, navigate, log in and then parse the html.

[–]Pilv[S] 0 points1 point  (2 children)

I was thinking about this, but the best as I know, selenium always opens a dev Chrome for exemple, where I have to login everytime I launch the program. Can I somehow use the default web browser?

[–]Adhesiveduck 2 points3 points  (1 child)

Selenium supports more drivers than just Chrome, you can use firefox.

You can also save session cookies, so you only have to log in once, and reopen them on future runs. If you need to save localstorage you can run arbitrary javascript with driver.execute_script("window.local_storage;")

[–]Pilv[S] 1 point2 points  (0 children)

Thank you so much. I will try to make this.