phantomjs

Casperjs fill input without name

时间秒杀一切 提交于 2020-01-14 04:33:05
问题 i want to use facebook share dialog Link to share dialog with casperjs i managed to select the post mode "group" from the first dropdown , but i failed when i tired to fill the group name input (i think it use ajax drop down list) Screenshot of result with no luck , here is my code . var casper = require('casper').create({ pageSettings: { loadImages: false, loadPlugins: true, userAgent: 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0' }, logLevel: "info", verbose:

轻松入门学网络爬虫编程实战(1):音乐歌单篇

谁说胖子不能爱 提交于 2020-01-14 02:12:52
为想学Python或正在进阶的小伙伴提供一种轻松的入门方式,小编会由浅入深的详解爬虫技术。 介绍 什么是爬虫? 先看看百度百科的定义: 把这段代码保存为get_html.py,然后运行,看看输出了什么: 定位到的html代码: 有了这些信息,就可以用BeautifulSoup提取数据了。升级一下代码: 把这段代码保存为get_data.py,然后运行,看看输出了什么: 没错,得到了我们想要的数据! BeautifulSoup提供一些简单的、Python式的函数用来处理导航、搜索、修改分析树等功能。它是一个工具箱,通过解析文档为用户提供需要抓取的数据,因为简单,所以不需要多少代码就可以写出一个完整的应用程序。怎么样,是不是觉得只要复制粘贴就可以写爬虫了?简单的爬虫确实是可以的! 一个迷你爬虫 我们先定一个小目标:爬取网易云音乐播放数大于500万的歌单。 打开歌单的url: http://music.163.com/#/discover/playlist,然后用BeautifulSoup提取播放数<span class=”nb”>3715</span>。结果表明,我们什么也没提取到。难道我们打开了一个假的网页? Selenium:是一个强大的网络数据采集工具,其最初是为网站自动化测试而开发的。近几年,它还被广泛用于获取精确的网站快照,因为它们可以直接运行在浏览器上。Selenium

PhantomJS: Add Javascript include to web page (not to PhantomJS environment)

空扰寡人 提交于 2020-01-13 18:55:29
问题 I would like to add a JavaScript <script></script> tag, containing or sourcing untrusted code, to web pages PhantomJS visits, and have the page behave as if the page originally included the tag. includeJs() / injectJs() do not do what I need - they inject code into my PhantomJS environment, but I need my code injected into the web page. Further, these functions expose my PhantomJS local variables to the untrusted code, which I do not want. evaluate() does not do what I need either, as it will

testing DOM elements with phantomjs/casperjs

老子叫甜甜 提交于 2020-01-13 17:26:40
问题 I've got an AJAX-based javascript application which I would like to cover with interface tests. For example, I would like to write a test that loads my website (from a given URL) and checks if there are some DOM elements (given ids and given classes) that exist. The problem is that when I enter the URL in a browser, my application has a Loading... label displayed and an AJAX request is sent beneath. When AJAX response arrives, some processing is done and the right webpage content is displayed

Error: Unexpected request: GET views/partials/* for a nested directive even when using html2js in karma/jasmine unit test

戏子无情 提交于 2020-01-13 09:29:47
问题 I am using Karma and Jasmine for unit testing for my angularjs application. I have a directive's(say Directive A) template in which another directive(say Directive B) is getting rendered, although it is working fine in application but test case fails to render the Directive B's template. Following is the error I get :- Error: Unexpected request: GET views/partials/directiveb.html Expected GET https://my-sandbox.app.com/123456 Below is the directive A's code :- angular.module('myApp')

How to 'convert' variable of type instance such that the variable can be used to authenticate when making system calls

佐手、 提交于 2020-01-13 07:06:08
问题 I'm using https://code.google.com/p/python-ntlm/ for authenticating and then using a system call to get the response from YSlow. I am not quite sure on how to 'convert' the needed info to a variable that will provide me the response I desire. I tried other solutions...but here I am... user = 'domain\userName' password = "password" url = "http://someUrlHere.com" # User must be granted access in order for script to work... passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password

selenium with PhantomJs wait till page fully loaded?

Deadly 提交于 2020-01-12 21:42:23
问题 I use Selenium with Phantomjs, and want to get the page content after the page fully loaded. I tried http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp but it seems not working with phantomjs Explicit wait: using (IWebDriver driver = new PhantomJSDriver()) { IWait<IWebDriver> wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(30.00)); wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete")); driver

Saving table data obtained while scraping a webpage using casperjs [closed]

做~自己de王妃 提交于 2020-01-12 04:00:06
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . Which would be the best method to save table data obtained while scraping a webpage using casperjs? Using a json object and store it as a file after serializing. Using ajax request to php then storing it in a mysql db. 回答1: For simplicity sake, view CasperJS as a way to

Is there a way to read user input from keyboard for PhantomJS?

人盡茶涼 提交于 2020-01-11 17:10:57
问题 I'm using PhantomJS to login website and the captcha has to be inputed manually. How can I save the captcha image to disk, and then input the captcha by hand in PhantomJS console? 回答1: I had the same problem, just use the system module in combination with a page.render() and some argument passing to page.evaluate. page.render('pagewithcatpcha.jpg'); page.injectJs('http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'); var arg1 = consoleRead(); page.evaluate(function (arg1) { $('

Is there a way to read user input from keyboard for PhantomJS?

房东的猫 提交于 2020-01-11 17:08:29
问题 I'm using PhantomJS to login website and the captcha has to be inputed manually. How can I save the captcha image to disk, and then input the captcha by hand in PhantomJS console? 回答1: I had the same problem, just use the system module in combination with a page.render() and some argument passing to page.evaluate. page.render('pagewithcatpcha.jpg'); page.injectJs('http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'); var arg1 = consoleRead(); page.evaluate(function (arg1) { $('