mass-populate.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:open-house-crawler 作者: data-skeptic 项目源码 文件源码
def run(query):
    r = requests.get('https://en.wikipedia.org/wiki/List_of_United_States_cities_by_population')
    soup = BeautifulSoup(r.content)
    #
    tbl = soup.find_all('table')[3]
    df = pd.read_html(str(tbl))[0]
    #
    df.columns = df.iloc[0]
    #
    cities = df['City'].tolist()
    #
    for city in cities:
        i = city.find('[')
        if i != -1:
            city = city[0:i]
        city = city + ' ' + query
        print(city)
        populate.query_and_post(city)
        time.sleep(1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号