主类,进行爬取,存入redis,需要更换cookie
import random
import uuid
from time import sleep
import redis
import requests
from lxml import etree
class Spider():
def __init__(self):
self.store_client = redis.Redis(host='127.0.0.1')
self.store_client1 = redis.StrictRedis()
def start_spider(self,cookie):
url = 'https://www.xinpianchang.com/channel/index/sort-like?from=tabArticle&ajax=1&page=%d'
with open('1.txt','r') as f:
page = f.read()
print(page)
while (page):
sleep(random.randint(1, 6))
try:
data_url = self.get_data(url % int
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30