代码拉取完成,页面将自动刷新
1.
import scrapy
class LessonSpider(scrapy.Spider):
name = 'lesson'
allowed_domains = ['https://www.imooc.com/course/list']
start_urls = ['https://www.imooc.com/course/list']
def parse(self, response):
print(response.status)
biaoti = response.xpath("//div[@class='img']/@style").getall()
print(biaoti)
xzcs = response.xpath("//p[@class='title ellipsis2']/text()").getall()
print(xzcs)
tplj = response.xpath("//a[@class='item free ']/p[2]/text()").getall()
print(tplj)
danjia = response.xpath("//span[@class='l']/text()").getall()
print(danjia)
2.
import scrapy
class LessonSpider(scrapy.Spider):
name = 'lesson'
allowed_domains = ['http://www.1ppt.com/moban/']
start_urls = ['http://www.1ppt.com/moban/']
def parse(self, response):
print(response.status)
biaoti = response.xpath("//dl[@class='dlbox']/dd/ul/li/h2/a/text()").getall()
print(biaoti)
xzcs = response.xpath("//ul[@class='tplist']/li/span/text()[2]").getall()
print(xzcs)
tplj = response.xpath("//ul[@class='tplist']/li/a/img/@src").getall()
print(tplj)
3.
import scrapy
class LessonSpider(scrapy.Spider):
name = 'lesson'
allowed_domains = ['https://jh.lianjia.com/ershoufang/']
start_urls = ['https://jh.lianjia.com/ershoufang/']
def parse(self, response):
print(response.status)
biaoti = response.xpath("//div[@class='title']/a/text()").getall()
print(biaoti)
xzcs = response.xpath("//div[@class='houseInfo']/text()").getall()
print(xzcs)
tplj = response.xpath("//div[@class='totalPrice totalPrice2']/span/text()").getall()
print(tplj)
danjia = response.xpath("//div[@class='unitPrice']/span/text()").getall()
print(danjia)
4.
import scrapy
class LessonSpider(scrapy.Spider):
name = 'lesson'
allowed_domains = ['https://hotel.qunar.com/']
start_urls = ['https://hotel.qunar.com/']
def parse(self, response):
print(response.status)
biaoti = response.xpath("//p[@class='name text-elli-one']/text()").getall()
print(biaoti)
xzcs = response.xpath("//p[@class='score']/span/text()").getall()
print(xzcs)
tplj = response.xpath("//p[@class='comm_num']/text()").getall()
print(tplj)
danjia = response.xpath("//p[@class='price']/text()").getall()
print(danjia)
5.
import scrapy
class LessonSpider(scrapy.Spider):
name = 'lesson'
allowed_domains = ['https://china.nba.com/static/data/league/playerstats_All_All_All_0_All_false_2021_2_All_Team_points_All_perGame.json']
start_urls = ['https://china.nba.com/static/data/league/playerstats_All_All_All_0_All_false_2021_2_All_Team_points_All_perGame.json']
def parse(self, response):
print(response.status)
xhtml = response.json()
for i in range(50):
print(xhtml['payload']['players'][i]['playerProfile']['displayName'])
print(xhtml['payload']['players'][i]['teamProfile']['displayAbbr'])
print(xhtml['payload']['players'][i]['statAverage']['pointsPg'])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。