![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
peng864534630
这个作者很懒,什么都没留下…
展开
-
python-json字符串至字典
json转化import jsondic='{"name":"zhangsan","age": 23,"id":201811110,"url":"http://internal-mrp.salad.net-a-porter.com{business}"}'s_json=json.loads(dic)print(s_json)print(s_json['url'])输出结果:{'ur原创 2018-03-30 10:32:24 · 263 阅读 · 0 评论 -
python爬取网页—网站编码
在爬取网站之前需要查看网页的编码方式,对应的,通过查看网页源代码,在网站页面配合按键F12 ctrl+F 搜索"charset"可找到如下类似信息:<meta http-equiv="Content-Type" content="text/html; charset=gb2312">...网页抓取,要查看编码格式,发现是gbk格式的,抓取时候,你的python系统是不认识,你的subl...原创 2018-03-30 11:26:01 · 603 阅读 · 0 评论 -
python中正则表达式
正则表达式匹配流程:正则表达式文本compile后得到正则表达式对象,在正则表达式对象中定义了不同的操作提供方法,如模式匹配搜索或字符串替换。下图展示了使用正则表达式进行匹配的流程: 1. pat_details = re.compile(r'"editorsComments":"(.*?)",', re.MULTILINE | re.DOTALL) script_det...原创 2018-04-02 11:16:21 · 172 阅读 · 0 评论 -
正则
<div class="article-intro" id="content"> <h1>Python 正则表达式</h1><p>正则表达式是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配。</p><p>Python 自1.5版本起增加了re 模块,它提供 Perl原创 2018-04-02 11:23:52 · 231 阅读 · 0 评论 -
python+selenium+webdriver+chromedriver
今天用到selenimu中的webdriver,在安装外selenium后,输入以下程序出现错误:"'chromedriver' executable needs to be in PATH":from selenium import webdriverchromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedr...原创 2018-04-03 11:08:14 · 2450 阅读 · 0 评论 -
python爬虫 Selenium元素定位方法
1.定位页面中一个元素:find_element_by_idfind_element_by_namefind_element_by_xpath(常用)find_element_by_link_textfind_element_by_partial_link_textfind_element_by_tag_namefind_element_by_class_namefind_element_原创 2018-04-23 14:57:48 · 628 阅读 · 0 评论 -
python selenium中浏览器操作
1.关闭浏览器全部标签页driver.quit()2.关闭当前标签页(从标签页A打开新的标签页B,关闭标签页A)driver.close()3.关闭当前标签页(从标签页A打开新的标签页B,关闭标签页B)可利用浏览器自带的快捷方式对打开的标签进行关闭Firefox自身的快捷键分别为:Ctrl+t 新建tabCtrl+w 关闭tab原创 2018-04-23 15:09:24 · 999 阅读 · 0 评论 -
python selenium操作浏览器窗口切换
说明:打开新的窗口,然后从多个窗口中定位到新的窗口方法一:# 获取打开的多个窗口句柄' windows = driver.window_handles '# 切换到当前最新打开的窗口driver.switch_to.window(windows[-1]) 方法二:判断窗口句柄# 获得打开的第一个窗口句柄window_1 = driver.current_window_h原创 2018-04-23 21:09:42 · 1676 阅读 · 0 评论