栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

抓取的HTML与源代码有何不同?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

抓取的HTML与源代码有何不同?

您可以为此目的使用Selenium。它将像浏览器一样在运行时呈现您的网页。您可以将Selenium与firefox,chrome或phantomjs一起使用。

由于大多数站点都是由现代Javascript框架组成的,因此我们基本上使用硒来完全呈现我们的网页。通常,它用于开发爬网程序/爬网程序以从网站的不同页面收集数据,或者Selenium也用于网络自动化。

有关Selenium的更多信息,请在此处阅读:http:
//selenium-
python.readthedocs.io/另外,我还为初学者撰写了有关Slenium的博客文章。也检查一下这个http://blog.hassanmehmood.com/creating-
your-first-crawler-in-python/

import urllibfrom selenium import webdriverfrom selenium.webdriver.common.keys import Keysprofile_link = 'http://hassanmehmood.com'class TitleScrapper(object):    def __init__(self):        fp = webdriver.FirefoxProfile()        fp.set_preference("browser.startup.homepage_override.mstone", "ignore") #Avoid startup screen        fp.set_preference("startup.homepage_welcome_url.additional",  "about:blank")        self.driver = webdriver.Firefox(firefox_profile=fp)        self.driver.set_window_size(1120, 550)    def scrape_profile(self):        self.driver.get(profile_link)        print self.driver.title        self.driver.close()    def scrape(self):        self.scrape_profile()if __name__ == '__main__':    scraper = TitleScrapper()    scraper.scrape()


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/612019.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号