0
ページ上のすべての記事のティーザータイトルを返そうとしています。どのページを検索しても下のコードが表示されても、私はrequests.getとBeautifulSoupを使用してページからタイトルを返します。
終了コード0で終了します。
誰かが間違っている場所を教えてください。私はPyCharm 2016.3.2とAnaconda3を使います。
おかげ
import requests
from bs4 import BeautifulSoup
if __name__ == "__main__":
# User agent to bypass scraping security
agent = {'User-Agent': 'Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405'}
req = requests.get("http://www.zerohedge.com/", agent)
#req.content = html page source and we are using the html parser
soup = BeautifulSoup(req.content, "html.parser")
for i in soup.find_all("title teaser-title"):
print(i.text)
おかげ@Zroqは、(H2)クラスタグは、私が行方不明になった部分でした。 –