有一點(diǎn)不太嚴(yán)謹(jǐn),p['paser']不是數(shù)組、列表、元祖,是字典的獲取語法
2020-02-18
for t in soup.find_all('a'): # for循環(huán)遍歷所有a標(biāo)簽,并把返回列表中的內(nèi)容賦給t
print('t的值是:', t) # link得到的是標(biāo)簽對象
print('t的類型是:', type(t))
print('a標(biāo)簽中的href屬性是:', t.get('href')) # 獲取a標(biāo)簽中的url鏈接
print('t的值是:', t) # link得到的是標(biāo)簽對象
print('t的類型是:', type(t))
print('a標(biāo)簽中的href屬性是:', t.get('href')) # 獲取a標(biāo)簽中的url鏈接
2020-01-14
之前講過的這個(gè)方式
html = urlopen("https://en.wikipedia.org/robots.txt").read().decode("utf-8")
print(html)
爬出來的結(jié)果,似乎還更有秩序一些?
html = urlopen("https://en.wikipedia.org/robots.txt").read().decode("utf-8")
print(html)
爬出來的結(jié)果,似乎還更有秩序一些?
2019-11-30