码迷,mamicode.com
首页 > 其他好文 > 详细

spider from mobile to mobile to mobile

时间:2017-08-19 14:26:04      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:pixel   path   url   use   pytho   nexus 5   useragent   highlight   from   

 

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

url_seed = ‘http://m.sogou.com/web/searchList.jsp?pid=sogou-mobb-123asd-0007&keyword=百度地图‘
mobile_emulation = {
    "deviceMetrics": {"width": 360, "height": 640, "pixelRatio": 3.0},
    "userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19"}
chrome_options = Options()
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
browser = webdriver.Chrome(chrome_options=chrome_options)

browser.get(url_seed)
js = ‘document.getElementsByClassName("input-default js_input")[0].value="深圳市南山区海岸城"‘
browser.execute_script(js)
xp = ‘//*[@id="sogou_vr_21384401_1_wrap"]/div/div[1]/a‘
browser.find_element_by_xpath(xp).click()

  

spider from mobile to mobile to mobile

标签:pixel   path   url   use   pytho   nexus 5   useragent   highlight   from   

原文地址:http://www.cnblogs.com/yuanjiangw/p/7396160.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!