1

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.

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.