ksvmuralidhar
commited on
Commit
•
4f473a5
1
Parent(s):
cd8a76c
Update scraper.py
Browse files- scraper.py +1 -6
scraper.py
CHANGED
@@ -8,19 +8,14 @@ import os
|
|
8 |
|
9 |
async def get_text(url, n_words=15):
|
10 |
try:
|
11 |
-
# geckodriver_path ='/home/user/app/geckodriver'
|
12 |
-
# os.environ['PATH'] += ':' + geckodriver_path
|
13 |
-
# os.environ['SELENIUM_DRIVER_CAPABILITIES'] = '{"alwaysLoadVcDrivers": true}'
|
14 |
driver = None
|
15 |
logging.warning(f"Initiated Scraping {url}")
|
16 |
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
|
17 |
opts = FirefoxOptions()
|
18 |
opts.add_argument("--headless")
|
19 |
opts.add_argument(f"user-agent={user_agent}")
|
20 |
-
# opts.binary = geckodriver_path
|
21 |
-
# webdriver.firefox.driver = geckodriver_path
|
22 |
driver = webdriver.Firefox(options=opts)
|
23 |
-
driver.set_page_load_timeout(
|
24 |
driver.get(url)
|
25 |
elem = driver.find_element(By.TAG_NAME, "body").text
|
26 |
sents = elem.split("\n")
|
|
|
8 |
|
9 |
async def get_text(url, n_words=15):
|
10 |
try:
|
|
|
|
|
|
|
11 |
driver = None
|
12 |
logging.warning(f"Initiated Scraping {url}")
|
13 |
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
|
14 |
opts = FirefoxOptions()
|
15 |
opts.add_argument("--headless")
|
16 |
opts.add_argument(f"user-agent={user_agent}")
|
|
|
|
|
17 |
driver = webdriver.Firefox(options=opts)
|
18 |
+
driver.set_page_load_timeout(30)
|
19 |
driver.get(url)
|
20 |
elem = driver.find_element(By.TAG_NAME, "body").text
|
21 |
sents = elem.split("\n")
|