code-tutorial.com

The best resources for developers

What are some examples of options for HTML scraping?

from __future__ import with_statement
import re, os

profile = ""

os.system("wget --no-cookies --header "Cookie: soba=(SeCreTCODe)" http://stackoverflow.com/users/30/myProfile.html")
with open("myProfile.html") as f:
    for line in f:
        profile = profile + line
f.close()
p = re.compile("summarycount">(d+)</div>") #Rep is found here
print p
m = p.search(profile)
print m
print m.group(1)
os.system("espeak "Rep is at " + m.group(1) + " points""
os.remove("myProfile.html")

Tags: html html-parsing html-content-extraction web-scraping

Source: By Mark Harrison as answer to the question

This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 4.0


Related code-snippets: