簡單爬爬企查查

2021-09-11 14:04:57 字數 974 閱讀 9538

本來準備爬取天眼查的,但發現天眼查在不付費的情況下,只能看到前10頁的內容,後面的在網頁源**中也無法看到,所以選擇了抓取企查查(後來發現利用robot.txt也可以爬取天眼查),**見下:

from selenium import webdriver

import time

import pymongo

import random

client = pymongo.mongoclient(host = 'localhost', port = 27017)

db = client.qichacha

collection = db.intelnational_organization

driver = webdriver.chrome()

for i in range(1 , 501):

url = ''%i

driver.get(url)

time.sleep(2 + random.random())

tb = driver.find_element_by_xpath("./html/body/div[2]/div/div[2]").text

time.sleep(5 + 15 * random.random())

if tb:

col =

collection.insert(col)

print(i)

else:

print("fail %d")%i

break

這段**自身沒有多少技術含量,關鍵點在於如何使自身的ip不會被封掉,於是運用了time庫中的sleep函式以及random隨機時間。如果根據行業更換url, 則可以抓取所有的企業,本人已親測可行。事實上也可以對其進行封裝!

特別宣告:

本部落格所有內容及其附加產品僅用於學術研究,如有人對此商用造成的法律後果,本部落格概不負責!! !

企查查介面php版本

對接企業三要素驗證ps 這裡的key和secretkey都是直接在你的企查查賬戶裡面能看到的 引數 廢話不多說直接上 public function companyverify regno companyname frname timespan time 加密 token strtoupper md...

簡單爬取小說

import urllib.request import re 爬取 是最基礎的爬蟲,學會思路就能去做一些高階爬蟲,思路一樣,只是用的庫或者js或者非同步等問題不同而已 url 爬取的 with urllib.request.urlopen url as doc html doc.read 讀取網頁...

爬爬爬,爬蟲之獲取資料 requests

推薦使用requests庫,相比urllib使用要簡介的多 requests向目標站點傳送請求,獲得乙個httpresponse響應 import requests requests.get requests.post requests.put requests.delete requests.he...