python - 如何从 https ://stackoverflow. com/?tab=month 中提取元素(标题名称、投票、 View 、每个标题的答案)?

标签 python python-3.x file dictionary

我可以弄清楚读取页面并将文本存储到文件部分 (urllib2) 但不能提取元素 (votes, title ,...)。 页面是https://stackoverflow.com/?tab=month

如何写一个python脚本获取一个网页然后提取所有的标题,没有。每个问题收到的观点、投票和答案?

最佳答案

如果要抓取页面,可以使用像scrapy 这样的库。 ,但 stackoverflow 具有非常好用且易于使用的 REST API,具有排序功能,您可以在此处访问和阅读: https://api.stackexchange.com/docs/ 例如,要检索问题,请参阅此页面: https://api.stackexchange.com/docs/questions

关于python - 如何从 https ://stackoverflow. com/?tab=month 中提取元素(标题名称、投票、 View 、每个标题的答案)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47349629/

相关文章:

python - SQLAlchemy - 访问反射表的别名列时出现 NoReferencedTableError 异常

python - Python3(anaconda)中的tkinter, "AttributeError: module ' tkinter'没有属性 'Tk'“

python - 是否有优雅或 Pythonic 的方式来中断线程中的 time.sleep() 调用?

python - list() 函数混淆

python 3导入所有包与一部分

android - 将私有(private)文件写入内部存储

python - 将 Crispy Form 与 ListView 结合使用

python-3.x - python numba指纹错误

Python 文件() 函数

java - BufferedWriter 将随机字母写入文件(Java)