鬼泣4se设置那里的总体屏幕质量和材质分辨率是什么意思?

鬼泣

呵呵 呵呵
回答
  • destiny destiny

    看到这个问题必须来怒答一波~用python爬虫爬便宜机票了解一下?喜欢旅行又怕吃土?让python来爬取最便宜机票吧!图源:
    videoblocks.com
    你喜欢旅行吗?这个问题通常会得到一个肯定的答案,随后引出一两个有关之前冒险经历的故事。大多数人都认为旅行是体验新文化和开阔视野的好方法。但如果问题是“你喜欢搜索机票的过程吗?也许话题就到此为止了…
    可事实上,便宜的机票往往也很重要!本文将尝试构建一个网络爬虫,该爬虫对特定目的地运行并执行带有浮动日期(首选日期前后最多三天)的航班价格搜索。它会将结果保存为excel文件并发送一封包含快速统计信息的电子邮件。显然,这个爬虫的目的就是帮助我们找到最优惠的价格!你可以在服务器上运行脚本(一个简单的raspberry pi就可以),每天运行一到两次。结果会以邮件形式发送,建议将excel文件存入dropbox文件夹,以便随时随地查看。因为爬虫以“浮动日期”进行搜索,所以它会搜索首选日期前后最多三天的航班信息。尽管该脚本一次仅运行一对目的地,但可以很容易地改写该爬虫使其每个循环运行多个目的地。最终甚至可能找到一些错误票价.那会很有意思!另一个爬虫
    某种意义上来讲,网络爬取是互联网“工作”的核心。也许你认为这是一个十分大胆的说法,但谷歌就是从拉里·佩奇用j**a和python构建的网络爬虫开始的。爬虫不断地爬取信息,整个互联网都在试图为所有问题提供最佳的可能答案。网络爬取有不计其数的应用程序,即使更喜欢数据科学中的其他分支,你仍需要一些爬取技巧以获得数据。这里用到的一些技术来自于最近新的一本佳作《python网络数据采集》,书中包含与网络爬取相关的所有内容,并提供了大量简例和实例。甚至有一个特别有意思的章节,讲述如何解决验证码检验的问题。python的拯救
    第一个挑战就是选择爬取信息的平台,本文选择了客涯(kayak)。我们试过了momondo,天巡(skyscanner),亿客行(expedia)和其它一些网站,但是这些网站上的验证码特别变态。在那些“你是人类吗?的验证中,尝试了多次选择交通灯、十字路口和自行车后,客涯似乎是最好的选择,尽管短时间内加载太多页面它会跳出安全检查。我们设法让机器人每4到6个小时查询一次网站,结果一切正常。虽然说不定哪个部分偶尔会出点小问题,但是如果收到验证码,既可以手动解决问题后启动机器人,也可以等待几小时后的自动重启。如果你是网络爬取新手,或者不知道为何有些网站花费很大力气阻止网络爬取,那么为构建爬虫写下第一行代码前,你一定要多加努力。谷歌的“网络爬取规范”:
    http://lmgtfy.com/?q=web+scraping+etiquette
    系紧安全带.
    导入并打开chrome浏览器标签页后,会定义一些循环中会用到的函数。这个架构的构思大概是这样的:
    一个函数用于启动机器人程序,表明想要搜索的城市和日期。这个函数获得首轮搜索结果,按“最佳”航班排序,然后点击“加载更多结果”。另一个函数会爬取整个页面,并返回一个dataframe数据表。随后重复步骤2和步骤3,得出按“价格”和“航行时间”排序的结果。发送一封简要总结价格(最低价和平均价)的邮件,并将带有这三种排序类型的dataframe数据表保存为一份excel文件。以上所有步骤会在循环中重复,每x小时运行一次。每个selenium项目都以一个网页驱动器开始。我们使用chromedriver驱动器,但还有其它选择。phantomjs和firefox也很受欢迎。下载chromedriver后,将其置于一个文件夹中即可。第一行代码会打开一个空白chrome标签页。from time import sleep,strftime
    from random import randint
    import pandas as pd
    from selenium import webdriver
    from selenium.webdriver.common.keys import keys
    import smtplib
    from email.mime.multipart import mimemultipart
    change th** to your own chromedriver path!chromedriver_path='c:/{your path here}/chromedriver_win32/chromedriver.exe'
    driver=webdriver.chrome(executable_path=chromedriver_path)#th** will open the chrome window
    sleep(2)
    这些是将用于整个项目的包。使用randint函数令机器人在每次搜索之间随机睡眠几秒钟。这对任何一个机器人来说都是必要属性。如果运行前面的代码,应该打开一个chrome浏览器窗口,机器人会在其中导航。一起来做一个快速测试:在另一个窗口**问客涯网(http://kayak.com),选择往返城市和日期。选择日期时,确保选择的是“+-3天”。由于在编写代码时考虑到了结果页面,所以如果只想搜索特定日期,很可能需要做一些微小的调整。点击搜索按钮在地址栏获取链接。它应该类似于下面所使用的链接,将变量kayak定义为url,并从网页驱动器执行get方法,搜索结果就会出现。无论何时,只要在几分钟内使用get命令超过两到三次,就会出现验证码。实际上可以自己解决验证码,并在下一次验证出现时继续进行想要的测试。从测试来看,第一次搜索似乎一直没有问题,所以如果想运行这份代码,并让它在较长的时间间隔后运行,必须解决这个难题。你并不需要十分钟就更新一次这些价格,对吧?每个xpath都有陷阱
    到目前为止,已经打开了一个窗口,获取了一个网站。为了开始获取价格和其他信息,需要使用xpath或css选择器,我们选择了xpath。使用xpath导航网页可能会令人感到困惑,即使使用从inspector视图中直接使用“复制xpath”,但这不是获得所需元素的最佳方法。有时通过“复制xpath”这个方法获得的链接过于针对特定对象,以至于很快就失效了。《python网络数据采集》一书很好地解释了使用xpath和css选择器导航的基础知识。接下来,用python选择最便宜的结果。上面代码中的红色文本是xpath选择器,在网页上任意一处右键单击选择“inspect”就可以看到它。在想要查看代码的位置,可以再次右键单击选择“inspect”。为说明之前所观察到的从“inspector”复制路径的缺陷,请参考以下差异:
    1#th** ** what the copymethod would return.right click highlighted rows on the right side and select“copy>copy xpath”/*[@id=“wtki-price_atab”]/div[1]/div/div/div[1]/div/span/span
    2#th** ** what i used todefine the“cheapest”buttoncheap_results=‘/a[@data-code=“price”]’
    第二种方法的简洁性清晰可见。它搜索具有data-code等于price属性的元素a。第一种方法查找id等于wtki-price_atab的元素,并遵循第一个div元素和另外四个div和两个span。这次…会成功的。现在就可以告诉你,id元素会在下次加载页面时更改。每次页面一加载,字母wtki会动态改变,所以只要页面重新加载,代码就会失效。花些时间阅读xpath,保证你会有收获。不过,使用复制的方法在不那么“复杂”的网站上工作,也是很好的!基于以上所展示的内容,如果想在一个列表中以几个字符串的形式获得所有搜索结果该怎么办呢?其实很简单。每个结果都在一个对象中,这个对象的类是“resultwrapper”。获取所有结果可以通过像下面这样的for循环语句来实现。如果你能理解这一部分,应该可以理解接下来的大部分代码。它基本上指向想要的结果(结果包装器),使用某种方式(xpath)获得文本,并将其放置在可读对象中(首先使用flight_containers,然后使用flight_l**t)。前三行已展示在图中,并且可以清楚地看到所需的内容,但是有获得信息的更优选择,需要逐一爬取每个元素。准备起飞吧!最容易编写的函数就是加载更多结果的函数,所以代码由此开始。为了在不触发安全验证的前提下最大化所获取的航班数量,每次页面显示后,单击“加载更多结果”。唯一的新内容就是所添加的try语句,因为有时按钮加载会出错。如果它对你也有用,只需在前面展示的start_kayak函数中进行简要注释。load results to maximize the scraping
    def load_
    try:
    results='/a[@class=“morebutton”]'
    driver.find_element_by_xpath(more_results).click()
    printing these notes during the program helps me quickly check what it ** doing
    print('sleeping….')
    sleep(randint(45,60))
    except:
    pass
    现在,经过这么长的介绍,已经准备好定义实际爬取页面的函数。我们编译了下一个函数page_scrape中的大部分元素。有时这些元素会返回列表插入去程信息和返程信息之间。这里使用了一个简单的办法分开它们,比如在第一个 section_a_l**t和section_b_l**t变量中,该函数还返回一个flight_df数据表。所以可以分离在不同分类下得到的结果,之后再把它们合并起来。def page_scrape():
    “““th** function takes care of the scraping part”“
    xp_sections='/*[@class=“section duration”]'
    sections=driver.find_elements_by_xpath(xp_sections)
    sections_l**t=[value.text for value in sections]
    section_a_l**t=sections_l**t[:2]#th** ** to separate the two flights
    section_b_l**t=sections_l**t[1:2]#th** ** to separate the two flights
    if you run into a recaptcha,you might want to do something about it
    you will know there's a problem if the l**ts above are empty
    th** if statement lets you exit the bot or do something else
    you can add a sleep here,to let you solve the captcha and continue scraping
    i'm using a systemexit because i want to test everything from the start
    if section_a_l**t=[]:
    ra**e systemexit
    i'll use the letter a for the outbound flight and b for the inbound
    a_duration=[]
    a_section_names=[]
    for n in section_a_l**t:
    separate the time from the cities
    a_section_names.append(''.join(n.split()[2:5]))
    a_duration.append(''.join(n.split()[0:2]))
    b_duration=[]
    b_section_names=[]
    for n in section_b_l**t:
    separate the time from the cities
    b_section_names.append(''.join(n.split()[2:5]))
    b_duration.append(''.join(n.split()[0:2]))
    xp_dates='/div[@class=“section date”]'
    dates=driver.find_elements_by_xpath(xp_dates)
    dates_l**t=[value.text for value in dates]
    a_date_l**t=dates_l**t[:2]
    b_date_l**t=dates_l**t[1:2]
    separating the weekday from the day
    a_day=[value.split()[0]for value in a_date_l**t]
    a_weekday=[value.split()[1]for value in a_date_l**t]
    b_day=[value.split()[0]for value in b_date_l**t]
    b_weekday=[value.split()[1]for value in b_date_l**t]
    getting the prices
    xp_prices='/a[@class=“booking-link”]/span[@class=“price option-text”]'
    prices=driver.find_elements_by_xpath(xp_prices)
    prices_l**t=[price.text.replace('$','')for price in prices if price.text!'']
    prices_l**t=l**t(map(int,prices_l**t))
    the stops are a big l**t with one leg on the even index and second leg on odd index
    xp_stops='/div[@class=“section stops”]/div[1]'
    stops=driver.find_elements_by_xpath(xp_stops)
    stops_l**t=[stop.text[0].replace('n','0')for stop in stops]
    a_stop_l**t=stops_l**t[:2]
    b_stop_l**t=stops_l**t[1:2]
    xp_stops_cities='/div[@class=“section stops”]/div[2]'
    stops_cities=driver.find_elements_by_xpath(xp_stops_cities)
    stops_cities_l**t=[stop.text for stop in stops_cities]
    a_stop_name_l**t=stops_cities_l**t[:2]
    b_stop_name_l**t=stops_cities_l**t[1:2]
    th** part gets me the airline company and the departure and arrival times,for both legs
    xp_schedule='/div[@class=“section times”]'
    schedules=driver.find_elements_by_xpath(xp_schedule)
    hours_l**t=[]
    carrier_l**t=[]
    for schedule in schedules:
    hours_l**t.append(schedule.text.split('\n')[0])
    carrier_l**t.append(schedule.text.split('\n')[1])
    split the hours and carriers,between a and b legs
    a_hours=hours_l**t[:2]
    a_carrier=carrier_l**t[1:2]
    b_hours=hours_l**t[:2]
    b_carrier=carrier_l**t[1:2]
    cols=(['out day','out time','out weekday','out airline','out cities','out duration','out stops','out stop cities',
    'return day','return time','return weekday','return airline','return cities','return duration','return stops','return stop cities',
    'price'])
    flights_df=pd.dataframe({'out day':a_day,
    'out weekday':a_weekday,
    'out duration':a_...

类似问答
精品推荐

友情链接

友链互换QQ:

谷财 备案编号:蜀ICP备11019336号-3商务合作:235-677-2621

Copyright 2009-2020 Chengdu Sanzilewan Technology Co.,Ltd all rights reserve

抵制不良游戏 拒绝盗版游戏 注意自我保护 谨防受骗上当 适度游戏益脑 沉迷游戏伤身 合理安排时间 享受健康生活