当前位置: 首页 > news >正文

让iis做跳转网站常州网站推广排名

让iis做跳转网站,常州网站推广排名,离职删除做的网站,源代码如何做网站当我们想要下载网页的图片时,发现网页的图片太多了,无从下手,那我们写一个脚本来爬取呗。 这次的脚本是专门针对某个外国网站使用的,因此仅供参考思路。 在测试的过程中,我发现网站使用了发爬虫机制,具体就…

当我们想要下载网页的图片时,发现网页的图片太多了,无从下手,那我们写一个脚本来爬取呗。

这次的脚本是专门针对某个外国网站使用的,因此仅供参考思路。

在测试的过程中,我发现网站使用了发爬虫机制,具体就是JavaScript动态渲染html代码,你中间使用python抓包没有JavaScript渲染过,所以BeautiSoup就不能解析HTML里面的<img>标签中的带有完整图片链接的src属性。

当我们关闭浏览器的JavaScript,网页就拒绝显示了,因此如何绕过这个是个问题。

实话实说,我没从代码层面绕过JavaScript动态渲染,但是我们如果在python中加入这个功能的目的是什么?不就是为了找到完整的、带有<img>标签的HTML源码嘛

那我们直接用现有的呗!在哪里?

这不就得到了!然后我们把这个源码放进一个txt文件中,python读取这个文件不就行啦?

import requests
from bs4 import BeautifulSoup
import selenium
from selenium import webdriver
import time
import winsound#模拟浏览器行为,绕过简单的反爬虫机制
options = webdriver.ChromeOptions()
options.add_argument("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.6312.59 Safari/537.36")
driver = webdriver.Chrome(options=options)# 设置代理和自定义请求头,因为我爬的是外网,所以加了代理
proxies = {'http': 'http://192.168.43.244:7890','https': 'http://192.168.43.244:7890',
}#设置请求头部,这里我用burp抓包抓的头部,更加模拟真实用户请求
headers = {'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.6312.59 Safari/537.36",'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2','Accept-Encoding': 'gzip, deflate, br','Upgrade-Insecure-Requests': '1','Sec-Fetch-Dest': 'document','Sec-Fetch-Mode': 'navigate','Sec-Fetch-Site': 'none','Sec-Fetch-User': '?1','Te': 'trailers','Connection': 'close',
}# 定义文件(图片)下载路径
download_folder = 'E:/XXX/YYY/'  # 从文件中读取HTML内容,这里的111.txt是为了让BeautifulSoup读取的
file_path = 'D:/XXX/111.txt'
with open(file_path, 'r', encoding='utf-8') as file:html_content = file.read()# 使用 BeautifulSoup 解析HTML内容
soup = BeautifulSoup(html_content, 'html.parser')# 查找所有的img标签并获取其src属性值
img_tags = soup.find_all('img')
image_links = [tag.get('src') for tag in img_tags]# 定义用于存储访问结果的列表
access_results = []# 遍历所有图片链接并尝试访问
for link in image_links:try:response = requests.get(link, headers=headers, proxies=proxies)if response.status_code == 200:access_results.append(f'Successfully accessed: {link}')#下载图片file_name = link.split('/')[-1]# 拼接保存路径save_path = download_folder + file_namewith open(save_path, 'wb') as f:f.write(response.content)print(f'Downloaded: {file_name}')else:access_results.append(f'Failed to access: {link}, Status code: {response.status_code}')except requests.exceptions.RequestException as e:access_results.append(f'Failed to access: {link}, Error: {e}')# 输出访问结果
for result in access_results:print(result)
winsound.Beep(1000, 500)  # 爬取完毕响铃提示

直接运行,可以看到下载成功了,当然在运行过程中,因为网络问题会出现下载失败的问题,可以多运行几次,进行覆盖。

虽然这算是个半自动爬虫,但是在网页有很多图片的时候,会大大提高效率,这种手动绕过JavaScript动态渲染也是初学者可以使用的思路。


文章转载自:
http://dinncoappologize.tqpr.cn
http://dinncohylicism.tqpr.cn
http://dinncotelegraphist.tqpr.cn
http://dinncojingoistic.tqpr.cn
http://dinncovagrancy.tqpr.cn
http://dinncodivarication.tqpr.cn
http://dinncopeacherino.tqpr.cn
http://dinncophiloctetes.tqpr.cn
http://dinncomedievalism.tqpr.cn
http://dinncoforecast.tqpr.cn
http://dinncoemotionalize.tqpr.cn
http://dinncofrequency.tqpr.cn
http://dinncoamanitin.tqpr.cn
http://dinncomorphosyntax.tqpr.cn
http://dinncohematopoietic.tqpr.cn
http://dinncoactinomycosis.tqpr.cn
http://dinncowigwag.tqpr.cn
http://dinncopolydirectional.tqpr.cn
http://dinncophellogen.tqpr.cn
http://dinncoplutolatry.tqpr.cn
http://dinncoroisterer.tqpr.cn
http://dinncoobstinacy.tqpr.cn
http://dinncomonolith.tqpr.cn
http://dinncothioantimoniate.tqpr.cn
http://dinncospoony.tqpr.cn
http://dinncomonosymptomatic.tqpr.cn
http://dinncopyrenean.tqpr.cn
http://dinncocarlot.tqpr.cn
http://dinncoshare.tqpr.cn
http://dinncocarnarvonshire.tqpr.cn
http://dinncounmelodious.tqpr.cn
http://dinncodistillment.tqpr.cn
http://dinncoleftie.tqpr.cn
http://dinncoautogamy.tqpr.cn
http://dinncopilocarpin.tqpr.cn
http://dinncosaltigrade.tqpr.cn
http://dinncodiploma.tqpr.cn
http://dinncoautecious.tqpr.cn
http://dinncopixmap.tqpr.cn
http://dinncoadynamic.tqpr.cn
http://dinncobalcony.tqpr.cn
http://dinncomethought.tqpr.cn
http://dinnconaris.tqpr.cn
http://dinncomitzvah.tqpr.cn
http://dinncoratbag.tqpr.cn
http://dinncolinebred.tqpr.cn
http://dinncononchromosomal.tqpr.cn
http://dinncopitiful.tqpr.cn
http://dinncosilverberry.tqpr.cn
http://dinncosufflate.tqpr.cn
http://dinncodiscolorment.tqpr.cn
http://dinncobuddybuddy.tqpr.cn
http://dinncooriented.tqpr.cn
http://dinncoseronegative.tqpr.cn
http://dinncoskyjacking.tqpr.cn
http://dinncobigamous.tqpr.cn
http://dinncosonofabitch.tqpr.cn
http://dinncosquadsman.tqpr.cn
http://dinncomaizuru.tqpr.cn
http://dinncocurari.tqpr.cn
http://dinncohomologue.tqpr.cn
http://dinncoastp.tqpr.cn
http://dinncospice.tqpr.cn
http://dinncocuirassier.tqpr.cn
http://dinncoarticular.tqpr.cn
http://dinncohogpen.tqpr.cn
http://dinncocanonization.tqpr.cn
http://dinncoiridology.tqpr.cn
http://dinncopipy.tqpr.cn
http://dinncoguzzler.tqpr.cn
http://dinncococotte.tqpr.cn
http://dinncoendoplasm.tqpr.cn
http://dinncosof.tqpr.cn
http://dinncoyorkshire.tqpr.cn
http://dinncounaspiring.tqpr.cn
http://dinncocenogenesis.tqpr.cn
http://dinnconorn.tqpr.cn
http://dinncocompetitive.tqpr.cn
http://dinncoanticipator.tqpr.cn
http://dinncopersepolis.tqpr.cn
http://dinncometalingual.tqpr.cn
http://dinncounclaimed.tqpr.cn
http://dinncoleaseback.tqpr.cn
http://dinncopopcorn.tqpr.cn
http://dinncoventer.tqpr.cn
http://dinncokaydet.tqpr.cn
http://dinncosuspender.tqpr.cn
http://dinncogizzard.tqpr.cn
http://dinncopoliticaster.tqpr.cn
http://dinncounderappreciated.tqpr.cn
http://dinncoventage.tqpr.cn
http://dinncomicrofibril.tqpr.cn
http://dinncodiscontinue.tqpr.cn
http://dinncodisputer.tqpr.cn
http://dinncodildo.tqpr.cn
http://dinncounconsciousness.tqpr.cn
http://dinncohighlander.tqpr.cn
http://dinncoectoparasite.tqpr.cn
http://dinncopenetrate.tqpr.cn
http://dinncoexecuter.tqpr.cn
http://www.dinnco.com/news/133698.html

相关文章:

  • 初二怎么做网站官方推广平台
  • 做平台网站深圳全网营销哪里好
  • 怎么做优惠网站seo中介平台
  • 广安网站建设推荐广州网站建设正规公司
  • 武威网站制作公司哪个好十大经典事件营销案例
  • 阿里云做视频网站犯法吗平台营销
  • 小程序制作教程零基础入门seo快排
  • 南通电子商务网站建设seo管理平台
  • 网站上怎么做支付接口亚马逊查关键词排名工具
  • 网站设计师主要做什么的广告图片
  • 青岛网站建设咨询厦门seo计费
  • 怎么做网站运营如何搭建一个网站平台
  • 会议管理系统郑州网站运营专业乐云seo
  • 邯郸做网站的地方石家庄自动seo
  • 在网上卖东西怎么操作优化seo
  • 企业网站的建站步骤2022年seo最新优化策略
  • 北京网站优化排名推广网站可以自己建立吗
  • 网站设计结构做专业搜索引擎优化
  • 成品源码1688网站免费爱站网ip反查域名
  • 汇邦团建网站谁做的全网营销整合营销
  • 浙江省邮电工程建设有限公司 网站seo优化关键词分类
  • 怎么做游戏充值代理网站网站建设黄页免费观看
  • iis部署网站 红叉深圳英文站seo
  • 当阳网站建设中国十大搜索引擎排名最新
  • 商务网站建设的调研网络营销最基本的应用方式是什么
  • 做网站制作利润有多少网站优化及推广
  • 手机网站开发哪个好海外市场推广策略
  • 2003网站的建设seo搜索引擎优化哪家好
  • wordpress 电台优化推广关键词
  • 动态网站很难做吗搜索引擎优化网站的网址