我正在尝试从网站上打印2个号码,但这是输出: 这是html代码:
₪2,499
这是我的代码:
def connectToUrl():
print "Working:"
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
url = ""
response = opener.open(url)
page = response.read()
soup = BeautifulSoup(page, "lxml")
before = str(soup.find('del')).split(";")[-1]
after = str(soup.find('ins')).split(";")[-1]
tag_re = re.compile(r'(<!--.*?-->|<[^>]*>)')
no_tags_before = tag_re.sub('', str(before))
no_tags_after = tag_re.sub('',str(after))
before = cgi.escape(no_tags_before)
after = cgi.escape(no_tags_after)
return (before,after)