【发布时间】:2019-04-12 02:42:13
【问题描述】:
我正在尝试使用 Beautiful Soup 抓取 Android Store 页面,以获取包含软件包列表的文件。 这是我的代码:
from requests import get
from bs4 import BeautifulSoup
import json
import time
url = 'https://play.google.com/store/apps/collection/topselling_free'
response = get(url)
html_soup = BeautifulSoup(response.text, 'html.parser')
type(html_soup)
app_container = html_soup.find_all('div', class_="card no-rationale
square-cover apps small")
file = open("applications.txt","w+")
for i in range(0,60):
#if range > 60 ; "IndexError: list index out of range"
print(app_container[i].div['data-docid'])
file.write(app_container[i].div['data-docid'] + "\n")
file.close()
问题是我只能收集 60 个包名称,因为没有加载 javascript,如果我必须加载更多应用程序,我必须向下滚动。如何在 Python 中重现此行为以获得 60 多个结果?
【问题讨论】:
标签: javascript python beautifulsoup