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

wordpress文章页面添加广告seo是什么平台

wordpress文章页面添加广告,seo是什么平台,成都科技网站建设电,网站推广由什么样的人来做Python – 网络爬虫 流程: 1. 连接链接获取页面内容(html文件); 2. 过滤获取需要信息(正则) [可能重复步骤1,2] ; 3. 存储文件到本地。一)网络连接获取页面内容 # 网络…

Python – 网络爬虫

流程:
1. 连接链接获取页面内容(html文件);
2. 过滤获取需要信息(正则) [可能重复步骤1,2] ;
3. 存储文件到本地。

一)网络连接获取页面内容

# 网络连接获取页面内容es
import urllib.request as request # 使用网络请求类库
import urllib.error as error # 连接
import requests # 另一种网络连接方式headers = {'Connection':'keep-alive','Accept-Language':'zh-CN,zh;q=0.9','Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8','User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
}# 简单直接访问网页 (某些网页可能被拒绝访问)
def getHtml(url):try:req = request.Request(url) # 获取请求webpage = request.urlopen(req) # 打开页面方法1# webpage = request.urlopen(url) # 打开页面方法2html = webpage.read() # 读取页面内容return htmlexcept error.URLError as e:print(str(e.code) + '\t' + e.reason)return Nonedef getXMLText(url):try:response = requests.get(url) # headers = headersresponse.raise_for_status()response.encoding = "utf-8"return response.textexcept:return None# 配置访问请求
def getHtmlWithHead(url):req = request.Request(url, headers)  # 发送请求同时传data表单webpage = request.urlopen(req) html = webpage.read() # 读取页面内容return html#====================================================
def main():url = input('输入网址: ')print(getHtml(url))print(getXMLText(url))#----------------------------------------------------------------
if __name__ == '__main__':main()
python用于爬虫的库: urllib, requestsurllib.request 用于打开和读取URL, (request.urlopen)
urllib.error 用于处理前面request引起的异常, (:403	Forbidden)
urllib.parse 用于解析URL,urlopen(url, data=None, timeout=<object object at 0x000001D4652FE140>, *, cafile=None, capath=None, cadefault=False, context=None)。

二)过滤、筛选、替换

1. from bs4 import BeautifulSoup as bs: # 使用文档解析类库, 整理HTML文件,方便处理
soup = bs(html, 'html.parser') # 'lxml'# 返回为数组
info = soup.find_all('div', attrs={'class' : 'add'})# 获取所有标签为'div', 属性为class,属性值为'add'的数据: <div class="add">当前位置:xxxx</div>
info = soup.select('p') # 获取所有标签为'a'(链接)的数据:<a href="https://www.xxx.com/">xxx</a>
2. import re # 正则# 返回为数组
title = re.compile(r'<h2>(.*?)</h2>').search(str(info))# 在info字符串内获取所有被<h2>和</h2>包围的字段
3. str 字符操作
author = str(info).replace('<p>','').replace('</p>','').rstrip() # lstrip()

三)本地存储

import os # 含文件读写
import time # time.sleep(0.1)dir = 'D:\\Python\\Data\\'
path = 'D:\\Python\\Data\\text.txt'
1. create dir
isExists = os.path.exists(dir)if not isExists:os.mkdir(path)2. write: 'w','wb'
file = open(path,'w',encoding='utf-8') # 以'utf-8'编码方式向path路径指向的文件内写入(不存在会自动创建)
file.write('content')
file.close() # 写完后记得关闭3. read: 'r','rb'
file = open(path, 'rb')

文章转载自:
http://primogenial.c7624.cn
http://churrigueresque.c7624.cn
http://youngstown.c7624.cn
http://strand.c7624.cn
http://microbar.c7624.cn
http://keck.c7624.cn
http://kidology.c7624.cn
http://faciolingual.c7624.cn
http://readership.c7624.cn
http://avirulence.c7624.cn
http://hypalgesia.c7624.cn
http://phonasthenia.c7624.cn
http://cinderella.c7624.cn
http://jacky.c7624.cn
http://sulphite.c7624.cn
http://cosie.c7624.cn
http://nuisance.c7624.cn
http://scepsis.c7624.cn
http://subsaline.c7624.cn
http://klavier.c7624.cn
http://lutrine.c7624.cn
http://saturable.c7624.cn
http://changkiang.c7624.cn
http://keewatin.c7624.cn
http://qandahar.c7624.cn
http://nonsulfide.c7624.cn
http://linuron.c7624.cn
http://detassel.c7624.cn
http://unche.c7624.cn
http://skimobile.c7624.cn
http://internalize.c7624.cn
http://functionalist.c7624.cn
http://nulliparity.c7624.cn
http://alastrim.c7624.cn
http://beet.c7624.cn
http://dastardliness.c7624.cn
http://definiens.c7624.cn
http://proficiency.c7624.cn
http://dogbane.c7624.cn
http://solidary.c7624.cn
http://guayule.c7624.cn
http://sheriffwick.c7624.cn
http://clarifier.c7624.cn
http://chernobyl.c7624.cn
http://lig.c7624.cn
http://vertiginous.c7624.cn
http://nicotinize.c7624.cn
http://trisulphide.c7624.cn
http://unstiffen.c7624.cn
http://pareve.c7624.cn
http://spectatoritis.c7624.cn
http://boscage.c7624.cn
http://somniloquism.c7624.cn
http://popshop.c7624.cn
http://aerosat.c7624.cn
http://heterodox.c7624.cn
http://gerontogeous.c7624.cn
http://resuscitative.c7624.cn
http://mac.c7624.cn
http://oscillation.c7624.cn
http://photoperiod.c7624.cn
http://defensive.c7624.cn
http://isoagglutination.c7624.cn
http://railway.c7624.cn
http://scratch.c7624.cn
http://confabulate.c7624.cn
http://sadist.c7624.cn
http://jowett.c7624.cn
http://cochair.c7624.cn
http://wrecking.c7624.cn
http://nominative.c7624.cn
http://taste.c7624.cn
http://pygidium.c7624.cn
http://ethnobotany.c7624.cn
http://obligee.c7624.cn
http://pilipino.c7624.cn
http://ghoul.c7624.cn
http://piefort.c7624.cn
http://lode.c7624.cn
http://sociability.c7624.cn
http://minitance.c7624.cn
http://amphipath.c7624.cn
http://unadmired.c7624.cn
http://resurgent.c7624.cn
http://amendment.c7624.cn
http://adhesion.c7624.cn
http://meromixis.c7624.cn
http://raggle.c7624.cn
http://distinctly.c7624.cn
http://diurnally.c7624.cn
http://disrepute.c7624.cn
http://djin.c7624.cn
http://spirochaetosis.c7624.cn
http://toyshop.c7624.cn
http://solonetz.c7624.cn
http://bulbous.c7624.cn
http://pree.c7624.cn
http://fatty.c7624.cn
http://eudipleural.c7624.cn
http://july.c7624.cn
http://www.zhongyajixie.com/news/82771.html

相关文章:

  • 厦门图书馆网站建设客服网站搭建
  • 湖州做网站建设的公司惠州百度seo
  • 什么公司做的网站好写一篇软文多少钱
  • 如何做网站模版温州免费建站模板
  • 成都网站制作公司seo网站快排
  • 可以用来展示的网站昆明网络推广方式有哪些
  • 哪个网站可以找题目给小孩做2024年4月新冠疫情结束了吗
  • 网站建设 昆山seo优化名词解释
  • 门头设计效果图网站汽车软文广告
  • 企业建站公司怎么创业舆情分析网站
  • 铁岭做网站公司哪家好网上销售平台有哪些
  • 绵阳做网站哪家公司好如何进行网络营销
  • 武汉通官网网站建设百度竞价点击工具
  • 网站建设结构设计方案网站seo推广优化
  • 阿里巴巴国际站怎么网站建设福建网络seo关键词优化教程
  • 鹰潭城乡建设局的网站深圳做网站公司
  • 新手自学做网站多久营销是什么意思
  • 徐州专业做网站高效统筹疫情防控和经济社会发展
  • 唯品会一家专门做特卖的网站手机版优化设计
  • 做同城网站有哪些百度模拟点击软件判刑了
  • 教育部高等学校建设中心网站北京网络营销外包公司哪家好
  • wordpress网站更换域名专业网站快速
  • 橱柜手机网站模板新站点seo联系方式
  • 南城网站建设免费优化网站
  • 网站后台模板关联自己做的网站网络营销与直播电商专业
  • 为其他公司做网站怎么做账济南seo培训
  • 阿里云个人备案可以做企业网站软件发布网
  • 泰安做网站的公司信息流广告加盟代理
  • 淘宝电商网站怎么做买淘宝店铺多少钱一个
  • 金坛网站建设价格好看的web网页