我想抓住之间的所有html:
<table cellpadding="0" cellspacing="0" border="0" class="list" width="100%">
.
.
.
.
</tbody>
preg_match_all('XXXXXXXXXX', $this->markup, $links);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用jsoup编写一个天气刮刮Android应用程序.我有使用Java编写的代码,但即使是我在android中编写的最简单的形式也会引发错误.这是我的代码的一部分:
private class Retrieve_Weather extends AsyncTask<Void, Void, String> {
private final String TAG = "Retrieve_Weather";
protected String doInBackground(Void... params) {
String weatherline= "oTHErly";
Log.i(TAG, weatherline);
Document doc = null;
try {
Log.i(TAG, "trying document...");
doc = Jsoup.connect("http://m.wund.com/cgi-bin/findweather/getForecast?brand=mobile&query=02139").get();
Log.i(TAG, "after document");
weatherline = "newline";
}
catch (IOException except) {
Log.i(TAG, "Cannot Connect", except);
except.printStackTrace();
weatherline = "Can't Connect";
Log.i(TAG, "End stacktrace");
}
Log.i(TAG, weatherline);
return weatherline;
}
@Override
protected void onPreExecute() {
Log.i(TAG, "onPreExecute");
}
@Override
protected void onProgressUpdate(Void... values) { …Run Code Online (Sandbox Code Playgroud) 我注意到一个非常烦人的错误:BeautifulSoup4(包:) bs4经常找到比以前版本(包:)更少的标签BeautifulSoup.
这是该问题的可重现实例:
import requests
import bs4
import BeautifulSoup
r = requests.get('http://wordpress.org/download/release-archive/')
s4 = bs4.BeautifulSoup(r.text)
s3 = BeautifulSoup.BeautifulSoup(r.text)
print 'With BeautifulSoup 4 : {}'.format(len(s4.findAll('a')))
print 'With BeautifulSoup 3 : {}'.format(len(s3.findAll('a')))
Run Code Online (Sandbox Code Playgroud)
输出:
With BeautifulSoup 4 : 557
With BeautifulSoup 3 : 1701
Run Code Online (Sandbox Code Playgroud)
你可以看到,差异并不小.
以下是模块的确切版本,以防有人想知道:
In [20]: bs4.__version__
Out[20]: '4.2.1'
In [21]: BeautifulSoup.__version__
Out[21]: '3.2.1'
Run Code Online (Sandbox Code Playgroud) 你们知道我怎样才能获得所有img标签但是在使用xpath的id为footer的div下排除img标签?
目前要在html页面上获取所有img标签,我这样做:
imgs = tree.xpath('//img')
但我想在一个id为footer的div下排除所有img标签,所以我正在做这个:
imgs = tree.xpath('//*[not(div[@id="footer"])]//img') < - 但这不起作用
有人可以告诉我如何从这个网站上读取数据:http://www.amlbook.com/data/zip/features.train
我曾经在我的Matlab编辑器中复制+粘贴形成一个数组,但这次看起来数据量很大......
我在使用库selenium在python中使用脚本运行执行Webdriver时遇到了问题.我发布了示例代码方案以及执行时抛出的相应错误.
代码场景:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.python.org")
Run Code Online (Sandbox Code Playgroud)
错误场景:
Traceback (most recent call last):
File "C:/Users/Kaushik/Desktop/IMC DEVELOPER TEST/Sample.py", line 4, in <module>
driver = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\webdriver.py", line 59, in __init__
self.binary, timeout),
File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\firefox_binary.py", line 60, in launch_browser
self._start_from_profile_path(self.profile.path)
File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\firefox_binary.py", line 83, in _start_from_profile_path
env=self._firefox_env).communicate()
File "C:\Python27\lib\subprocess.py", line 709, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
startupinfo)
WindowsError: [Error 87] The parameter …Run Code Online (Sandbox Code Playgroud) 我正在尝试从Wikipedia页面获取重要图像,而不是缩略图或其他gif,并使用以下代码。但是,“ img”的长度为“ 0”。关于如何纠正它的任何建议。
代码:
import urllib
import urllib2
from bs4 import BeautifulSoup
import os
html = urllib2.urlopen("http://en.wikipedia.org/wiki/Main_Page")
soup = BeautifulSoup(html)
imgs = soup.findAll("div",{"class":"image"})
Run Code Online (Sandbox Code Playgroud)
另外,如果有人可以通过查看网页中的“源元素”来详细说明如何使用findAll。那太好了。
我有:
<div class="image" style="background-image: url('/uploads/images/players/16113-1399107741.jpeg');"
Run Code Online (Sandbox Code Playgroud)
我想获取网址,但是如果不使用正则表达式,我将无法做到这一点。可能吗?
到目前为止,我使用正则表达式的解决方案是:
url = re.findall('\('(.*?)'\)', soup['style'])[0]
Run Code Online (Sandbox Code Playgroud) 我需要一个javascript库来抓取一个Web应用程序.我找到了这个https://github.com/riccardo-forina/status-jquery-crawler,但正如作者声称的那样,这还处于开发的早期阶段.经过大量的谷歌搜索后我找不到任何东西感谢任何投入
web-scraping ×10
python ×4
javascript ×2
android ×1
datareader ×1
html ×1
html-table ×1
java ×1
jsoup ×1
matlab ×1
php ×1
r ×1
scrape ×1
selenium ×1
string ×1
url ×1
urllib ×1
web ×1
xpath ×1