37,720
社区成员
发帖
与我相关
我的任务
分享
import json
import time
import scrapy
from scrapy import Request
class BokeSpider(scrapy.Spider):
name = 'boke'
allowed_domains = ['blog.csdn.net']
start_urls = ['http://blog.csdn.net/']
def parse(self, response):
word = 'python'
shown_offset = int(time.time() * 1000000)
baser_url = 'https://blog.csdn.net/api/articles?type=more&category={0}&shown_offset={1}'.format(word, str(shown_offset))
yield Request(url=baser_url, callback=self.language_block, encoding='utf-8')
def language_block(self,response):
print('发出请求的链接是:', response.url)
json_str = json.loads(response.text)
print(json_str)
DEFAULT_REQUEST_HEADERS = {
'Accept':
'Accept-Language':
'User-Agent':
'cookie':
}