I have a problem with urllib in which I can't seem to scrape my own local website. I can get it to print out all the contents of the website but the regex or something doesn't work. The output I get with the current code is just []
. So I was wondering what I am doing wrong? I haven't used urllib in a while so it is very possible I missed something obvious. Python file:
import urllib
import re
htmlfile=urllib.urlopen('IP of server')
htmltext=htmlfile.read()
regex="<body>(.+?)</body>"
pattern=re.compile(regex)
price=re.findall(pattern,htmltext)
print price
HTML file:
<html>
<body>
This is a basic HTML file to try to get my python file to work...
</body>
</html>
Thanks a bunch in advance!