zoukankan      html  css  js  c++  java
  • 帮同学爬取某官方公众号的众多企业信息

    import requests
    import xlwt
    from bs4 import BeautifulSoup
    from threading import Thread
    # 725 1160
    def main():
        workbook = xlwt.Workbook()
        sheet1 = workbook.add_sheet('test', cell_overwrite_ok=True)
        first = 1
        for i in range(725, 1161): # 分析信息特点 
            response = requests.get("http://jingxinwei.wxshidai.com/jxj/style/detail?id=%d&redirect=1"%i)
            html = response.text
            soup = BeautifulSoup(html, "html.parser")
            print(i)
            # myWorkbook = xlwt.Workbook()
            w = 0
    
            for i in soup.select(".answerDesc"):  # 选择标签
                d = i.get_text().strip()    # 获取标签中的文本信息
                sheet1.write(first,w,d)  # 写入excel
                w += 1
            first += 1
        workbook.save("data.xls")
    
    t = Thread(target=main, args=())
    t.start()
  • 相关阅读:
    随笔练习
    获得屏幕相关的辅助类
    C# 下sqlite简单使用
    XP系统下 VS2010 选中行崩溃
    Custome Buble Data Point
    RIA
    Chart Style
    d3js
    TreeView
    [Java入门笔记] Java语言简介
  • 原文地址:https://www.cnblogs.com/cjj-zyj/p/10097735.html
Copyright © 2011-2022 走看看