Reputation: 19967
I wrote a small python script to programatically open url's in chrome every six seconds.
#!/usr/bin/env python
import webbrowser
import time
f = open("data.txt", "r")
urls = f.readlines()
safari = webbrowser.get('open -a /Applications/Google\ Chrome.app %s')
for url in urls:
safari.open(url.replace("\n", ""))
print url
time.sleep(6)
I'm wondering if there is a way to also capture HTTP errors (i.e. 404) from Chrome back into python.
Upvotes: 1
Views: 299
Reputation: 1340
I belive, it's not possible using webbrowser module. You should use something like selenium.
from seleniumrequests import Firefox
webdriver = Firefox()
response = webdriver.request('GET', 'https://www.google.com/')
print(response)
Upvotes: 1