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

外贸网络营销如何选取关键词天机seo

外贸网络营销如何选取关键词,天机seo,做网站策划的工具,百度seo视频教程下载chrome驱动 通过chrome浏览器的 设置-帮助-关于Google Chrome 查看你所使用的Chrome版本 驱动可以从这两个地方找: 【推荐】https://storage.googleapis.com/chrome-for-testing-publichttp://npm.taobao.org/mirrors/chromedriver import zipfile import os import r…

在这里插入图片描述

下载chrome驱动

通过chrome浏览器的 设置-帮助-关于Google Chrome 查看你所使用的Chrome版本
在这里插入图片描述

驱动可以从这两个地方找:

  • 【推荐】https://storage.googleapis.com/chrome-for-testing-public
  • http://npm.taobao.org/mirrors/chromedriver
import zipfile
import os
import requestsdef un_zip(file_name, to_dir='./'):"""unzip zip file"""zip_file = zipfile.ZipFile(file_name)if os.path.isdir(to_dir):passelse:os.mkdir(to_dir)for names in zip_file.namelist():zip_file.extract(names, to_dir)zip_file.close()def download_driver(url=None, to_dir='./', version=''):print('install chrome-driver first')if not url:url = 'http://npm.taobao.org/mirrors/chromedriver/LATEST_RELEASE'if len(version)>0:url = 'http://npm.taobao.org/mirrors/chromedriver/LATEST_RELEASE_'+versionversion = requests.get(url).content.decode('utf8')driver_file = 'http://npm.taobao.org/mirrors/chromedriver/' + version + '/chromedriver_win32.zip'else:driver_file = urlr = requests.get(driver_file)download_zip = "chromedriver_win32.zip"with open(download_zip, "wb") as code:code.write(r.content)un_zip(download_zip,  to_dir)# os.remove(download_zip)print('done')download_driver(url='https://storage.googleapis.com/chrome-for-testing-public/123.0.6312.58/win64/chromedriver-win64.zip', to_dir='./', version='')

数据库交互

把抓取的数据保存到数据库,sqlite数据库是一个db文件,可以用DBeaver工具打开,很方便

import sqlite3class DBC:def __init__(self, dbname):self.db = dbnameself.conn = Nonedef __enter__(self):self.conn = sqlite3.connect(self.db)return self.conndef __exit__(self, exc_type, exc_val, exc_tb):if exc_type is not None:self.conn.rollback()print("rollback")print(exc_type, exc_val, exc_tb)else:self.conn.commit()self.conn.close()def insert2db(data):with DBC('anjuke.db') as conn:cur = conn.cursor()cur.executemany("""insert into anjuke(community_name,year,address, tags, price, if_down, percent) values(?,?,?,?,?,?,?)""", data) with DBC('anjuke.db') as conn:cur = conn.cursor()cur.execute("""drop table if exists anjuke""")cur.execute("""create table if not exists anjuke(id INTEGER primary key  AUTOINCREMENT not null,community_name TEXT,year TEXT,address TEXT,tags TEXT,price TEXT,if_down BOOL,percent TEXT)""")

selenium 爪巴虫

import time
import traceback
from selenium import webdriverbrowser = webdriver.Chrome()
def process(url):browser.get(url)html = browser.page_sourcehtml = BeautifulSoup(html,)As = html.find_all("a", {"class": "li-row"})if len(As) == 0:raise Exception("EMPTY")data = []for A in As:price = A.find("div", {"class": "li-side"})price_value = price.find("div", {"class": "community-price"})if price_value:price_value = price_value.text.strip()minus = price.find("span")if minus:minus = 'propor-green' in minus.attrs['class']percent = price.find("span")if percent:percent = percent.text.strip()info = A.find("div", {"class": "li-info"})community_name = info.find("div", {"class": "nowrap-min li-community-title"}).textyear = info.find("span", {"class": "year"})if year:year = year.textadvantage =info.find("div", {"class":"prop-tags"})if advantage:advantage = advantage.text.strip()address = info.find("div", {"class": "props nowrap"}).find_all("span")[-1].textdata.append((community_name,year,address, advantage, price_value, minus, percent))insert2db(data)i = 0
while i < 50:  # 超过50显示重复数据i += 1url = f'https://hangzhou.anjuke.com/community/o8-p{i}'  # o2,o4,o6,o8不同排序条件print(url)try:process(url)except Exception as e:traceback.print_exc()s = input("check:")  # 抓取过程中,可能需要输入验证码i = i-1time.sleep(0.5)
http://www.yayakq.cn/news/518727/

相关文章:

  • 电子商务网站建设需求游戏网站模板html
  • 网站建设有哪些推广渠道常德生活网
  • uc官网网站开发者中心湛江免费建站哪里有
  • 深圳有没有做网站的网站正在建设中的
  • 网站建设类织梦模板.net开发的网站 能做成app吗
  • wordpress 增加磁盘容量如何优化网站内部链接
  • 自适应网站会影响推广网络公司网站模板html
  • 延平网站建设wzjseohtml标签 wordpress
  • 开发网站 公司购物网站开发设计思路
  • 优秀高端网站建设公司湖南网站推广多少钱
  • 营销型网站建设有哪些建站流程wordpress 滑动解锁
  • 西安做网站选哪家公司有建网站的软件
  • 移动端网站咋做宁波做公司网站公司
  • 个人网站的建设参考文献网站短片怎么做
  • 找外贸工作哪个网站好wordpress网店适合
  • 杭州电商网站开发网站如何运营
  • 网站流量 seo商丘网络推广平台
  • 顺德乐从网站建设网络规划设计师自学
  • 电商运营网站设计百度指数免费查询
  • 康巴什网站建设岳阳市建设局网站
  • 杭州的设计网站西安最新出入政策
  • 教学网站怎么做wordpress 相对路径
  • 网站管理登录东莞通网上营业厅
  • 荷泽网站建设页面跳转请记住新域名
  • 南京网站开发选南京乐识赞徐州招聘网站哪个好
  • 怎样管理一个俄语网站公司网站建设gghhhj
  • 手机怎样做自己的网站网站备案 影响吗
  • 物流wap网站模板即墨区城乡建设局网站
  • 网站备案工信部时间电商详情页设计公司
  • 做网络的网站很重要吗手机广告推广软件