摘要:
movie.py import scrapy from movieProject.items import MovieprojectItem class MovieSpider(scrapy.Spider): name = 'movie' allowed_domains = ['www.ygdy8. 阅读全文
摘要:
def parse(self, response): print('当当网') li = response.xpath('//ul[@id="component_59"]/li') #src,name,price有个共同的父元素li,但是对于第一个li,没有data-original,所以遍历根据l 阅读全文
摘要:
1.创建scrapy项目: 终端输入 scrapy startproject 项目名称 在spiders文件夹下创建py文件 scrapy genspider baidu http://www.baidu.com settings.py ROBOTSTXT_OBEY = False 4.运行爬虫文件 阅读全文
摘要:
import requests from lxml import etree import urllib.request url = 'https://so.gushiwen.cn/user/login.aspx?from=http://so.gushiwen.cn/user/collect.asp 阅读全文
摘要:
import requests url = 'http://www.baidu.com' res = requests.get(url)# 去除响应的乱码问题 res.encoding = 'utf-8' print(res.text) 3.response的属性以及类型 类型 :models.Re 阅读全文
摘要:
from selenium import webdriver path = 'chromedriver.exe' broswer = webdriver.Chrome(path) url = 'http://www.baidu.com' broswer.get(url) 元素定位: 1.find_e 阅读全文
摘要:
import urllib.request from lxml import etree # https://sc.chinaz.com/tupian/siwameinvtupian.html url = 'https://sc.chinaz.com/tupian/siwameinvtupian_2 阅读全文
摘要:
from lxml import etree # 获取本地文件 tree = etree.parse('bendi.html') print(tree) # /表示子元素,//表示子孙后代元素 li = tree.xpath('//body/ul/li') print(li) print(len(l 阅读全文