爱玺玺

爱玺玺的生活日记本。wx:lb87626

python安装requests No module named requests

Use pip install requests (or pip3 install requests for python3) if you have  pip installed and Pip.exe added to the Path Environment Variable. If pip is installed but not in your path you can use python -m

python selenium 增加cookie的写法格式要注意

1593497299(1).jpg

python selenium 通过xpath定位元素

1593415076(1).jpg

python 的 save_screenshot()默认保存路径是 C:\Users\Administrator

windows系统下:

python 的 save_screenshot()默认保存路径是 C:\Users\Administrator

selenium调用headless的firefox

  options = Options()

    options.add_argument('-headless')  # 无头参数

    driver = Firefox(executable_path='geckodriver', firefox_options=options)  # 配了环境变量第一个参数就可以省了,不然传绝对路径


第一个selenium程序

1593411102(1).jpg


效果:

windows selenium + geckodriver 安装

首先安装selenium在上一篇文章已介绍

再安装geckodriver

可以在官网下载

https://github.com/mozilla/geckodriver/releases

windows下安装selenium

python -m pip install selenium 

如果不使用python -m 安装使用

from selenium import webdriver 会报错


ubuntu使用find_element_by_id错误问题

以下代码为现敲,未测试

from selenium import  webdriver

driver=webdriver.PhantomJS()

driver.get("https://www.baidu.com/")

driver.find_elem

Python的BeautifulSoup理解,理解解析器

BeautifulSoup可以从html或xml中提取数据的Python库。

通过BeautifulSoup解析html可以得到一个BeautifuSoup对象。


获得一个BeautifulSoup对象:

from selenium import webdriver

from bs4 import BeautifulSoup as bs

driver = webdriver.PhantomJS()

drive

Powered By Z-BlogPHP 1.4 Deeplue Build 150101

Copyright Your WebSite.Some Rights Reserved.

蜀ICP备11021721号-5