我正在尝试为我的朋友开发一个 python 脚本,它将获取公共相册的链接,并使用“请求”模块计算每张照片的点赞数和评论数。这是我的脚本的代码
import re
import requests
def get_page(url):
r = requests.get(url)
content = r.text.encode('utf-8', 'ignore')
return content
if __name__ == "__main__":
url = 'https://www.facebook.com/media/set/?set=a.460132914032627.102894.316378325074754&type=1'
content = get_page(url)
content = content.replace("\n", '')
chehara = "(\d+) likes and (\d+) comments"
cpattern = re.compile(chehara)
result = re.findall(cpattern, content)
for jinish in result:
print "likes "+ jinish[0] + " comments " + jinish [1]
但这里的问题是,它只解析前 28 张照片的点赞和评论,而不是更多,这是什么问题?有人可以帮忙吗?
[编辑:模块“请求”只是加载网页,即变量内容包含链接相册的facebook网页的完整html源]