- #1
TheDemx27
Gold Member
- 169
- 13
I'm starting this web scraper, and all I'm trying to do so far is to just retrieve the source code from the sites.
Code:
I run it, and I get this error:
I'm using python 3.4.
Code:
Code:
import urllib.request
from urllib.request import urlopen
urls = ["[PLAIN]http://google.com",[/PLAIN] "[PLAIN]http://nytimes.com",[/PLAIN] "[PLAIN]http://www.rockpapershotgun.com/"][/PLAIN]
i = 0
while i < len(urls):
htmlfile = urllib.request.urlopen(urls)
htmltext = htmlfile.read()
print(htmltext)
i+=1
I run it, and I get this error:
Code:
Traceback (most recent call last):
File "C:\Python34\WebScraper.py", line 10, in <module>
htmlfile = urllib.request.urlopen(urls)
File "C:\Python34\lib\urllib\request.py", line 153, in urlopen
return opener.open(url, data, timeout)
File "C:\Python34\lib\urllib\request.py", line 446, in open
req.timeout = timeout
AttributeError: 'list' object has no attribute 'timeout'
[Finished in 0.2s with exit code 1]
I'm using python 3.4.
Last edited by a moderator: