試圖在打印輸出中抓住特定名稱。截至目前,代碼是這樣的......從循環中抓取特定單詞/打印
links = page_soup.findAll('div', attrs={'class' : 'gameLinks'})
for div in links:
print div.find('a')['href']
上面的代碼抓住所有的鏈接,給我大致50個鏈接,我只是想包含在URL中的單詞「redzone後面」等等。以下是其中包含redzone的鏈接的示例。
http://example.com/247075/1/nfl-redzone-live---never-miss-a-touchdown-live-stream-online.html
http://example.com/247075/2/nfl-redzone-live---never-miss-a-touchdown-live-stream-online.html
我在這裏錯過了什麼?
'link_href = div.find('a')['href'];如果link_href中的'redzone':print link_href' – mshsayem