Python 从Reddit中获取标题
在Reddit头版抓住头条新闻的最佳方式是什么?目前,我正在使用Python 从Reddit中获取标题,python,web-scraping,Python,Web Scraping,在Reddit头版抓住头条新闻的最佳方式是什么?目前,我正在使用BeautifulSoup4尝试删除它们,但使用RedditAPI似乎是一个可行的选择,但我在他们的文档中找不到要点击哪个URL来请求头条新闻。类似于http://www.reddit.com/r/frontpage/top.json?limit=10是我的猜测,但这并没有引起任何新闻标题 Python刮刀方法:(不工作) 有什么建议吗?在@jornsharpe的评论之后,有一个python Reddit API客户端: 用于
BeautifulSoup4
尝试删除它们,但使用RedditAPI似乎是一个可行的选择,但我在他们的文档中找不到要点击哪个URL来请求头条新闻。类似于http://www.reddit.com/r/frontpage/top.json?limit=10
是我的猜测,但这并没有引起任何新闻标题
Python刮刀方法:(不工作)
有什么建议吗?在@jornsharpe的评论之后,有一个python Reddit API客户端:
>>> import praw
>>> r = praw.Reddit(user_agent='my_cool_application')
>>> for item in r.get_top():
... print item
...
4901 :: I made a Redundant Clock.
4764 :: Elon Musk plans to launch 4,000 satellites to deliver high-speed Inte...
5144 :: Pipeline breach spills up 50,000 gallons of oil into the Yellowstone ...
4603 :: Avalanche Dog In Training
4564 :: TIL it is illegal in many countries to perform surgical procedures on...
...
还有,等等。你看过了吗?根据这篇文章,它只是https://www.reddit.com/top.json
。啊,这些都不是我的。使用r.get_front_page()可以获得所需的结果。
>>> import praw
>>> r = praw.Reddit(user_agent='my_cool_application')
>>> for item in r.get_top():
... print item
...
4901 :: I made a Redundant Clock.
4764 :: Elon Musk plans to launch 4,000 satellites to deliver high-speed Inte...
5144 :: Pipeline breach spills up 50,000 gallons of oil into the Yellowstone ...
4603 :: Avalanche Dog In Training
4564 :: TIL it is illegal in many countries to perform surgical procedures on...
...