link_node=soup.find('a', href=re.compile(r"ill"))
NameError: name 're' is not defined
NameError: name 're' is not defined
2018-04-12
現(xiàn)在百度的是https加密方式的了,而且目錄結(jié)構(gòu)也變了,所以寫的時候要改一下
比如使用Request對象
response = urllib2.urlopen(request,context = context)
頁面解析的話可以
links = soup.findAll('a',href=re.compile(r"/item/"))
這樣子就能匹配到了
比如使用Request對象
response = urllib2.urlopen(request,context = context)
頁面解析的話可以
links = soup.findAll('a',href=re.compile(r"/item/"))
這樣子就能匹配到了
2018-04-12
ModuleNotFoundError: No module named 'urlparse'
沒有這個模塊怎門辦
沒有這個模塊怎門辦
2018-04-09
輸出亂碼可嘗試做以下修改:
fout = open('output.html', 'w', encoding='utf-8') # 此處添加encoding='utf-8'
# 在fout.write("<html>")后添加這一行:
fout.write("<head><meta http-equiv='content-type' content='text/html;charset=utf-8'></head>")
fout = open('output.html', 'w', encoding='utf-8') # 此處添加encoding='utf-8'
# 在fout.write("<html>")后添加這一行:
fout.write("<head><meta http-equiv='content-type' content='text/html;charset=utf-8'></head>")
2018-04-08