-1

I want to extract information from a news site. When I run the Python script, there is a browser that launches and connects to an X site to extract the information I need.

Each time when I want to extract information, the browser must restart on each execution.

I want to leave the browser always launched, then I execute at any time a script which allows to extract the information.

Do you have an idea please? Thank you in advance.

AMC
  • 2,642
  • 7
  • 13
  • 35
  • There is already a good amount of information available on the subject, including right here on SO. – AMC Apr 10 '20 at 17:26

1 Answers1

0

There are 2 ways:

1) don't close the browser window once you open it.

don't use this: driver.close())

2) don't send a get request each time you modify your code.

don't do this more than once: driver.get("some url")

Suyash
  • 375
  • 6
  • 18
  • thanks but: I use the notion of class, a class which allows to launch Chrome and another which allows to extract information, so to make the connection I have to make a call of the class ChromeClass() in the other class for the extraction . So each time the browser is restarted another time. – DevPython057 Apr 10 '20 at 14:19
  • @DevPython057 you'll need to share the code for me to see that. However, if your code is private for some reason, no issue. From what I understand, here's what i can say: you should modify your code such that you open chrome only once in each time the code is run. – Suyash Apr 10 '20 at 14:23
  • The first file contains two functions, the first allows you to initialize Chrome and another which allows you to connect to an account. In the other file, I make a call to the two functions to launch the Chrome, then I launch a function which allows to extract the information. – DevPython057 Apr 10 '20 at 14:35