我对 VBA 非常有限,
代码在一个模块中,代码也有一个子进程,如果我把代码贴错了,很抱歉
该代码在 ebay.com 上运行良好,但不适用于 ebay.co.uk - 不知道为什么,它还将 url 转换为超链接
它只做第一页,我需要它浏览 X 个页面 - 有一个代码但无法让它工作,所以已将其删除。
是否可以在 Ebay 打开后运行搜索查询,因此它打开,然后将搜索项输入到 ebay,然后运行代码,或者从单元格运行,如果它的单元格 A1 提取的数据需要粘贴到 A2 及以下。
我查看了 ebay.com 和 ebay.co.uk 的元素,它们对我来说看起来一样,所以无法弄清楚为什么它不起作用,因为它适用于 1 而不是另一个。
我确实输入了从几个页面获取数据的代码,但它不起作用。我知道当我从谷歌获取 url 时,这段代码可以正常工作
Public IE As New SHDocVw.InternetExplorer
Sub GetData()
Dim HTMLdoc As MSHTml.HTMLDocument
Dim othwb As Variant
Dim objShellWindows As New SHDocVw.ShellWindows
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = True
'.Navigate "https://www.ebay.co.uk/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=jackets&_sacat=0"
.Navigate "https://www.ebay.com/sch/i.html_from=R40&_nkw=ralph+lauren&_sacat=1059&LH_TitleDesc=0&_dmd=1&rt=nc"
While .Busy Or .readyState <> 4: DoEvents: …Run Code Online (Sandbox Code Playgroud) 当 R 中没有使用 download.file() 上传特定文件时,是否有任何可能的解决方案可以从任何网站提取文件。
我有这个网址
https://www.fangraphs.com/leaders.aspx?pos=all&stats=bat&lg=all&qual=y&type=8&season=2016&month=0&season1=2016&ind=0
Run Code Online (Sandbox Code Playgroud)
有一个将 csv 文件导出到我的工作目录的链接,但是当我右键单击网页上的导出数据超链接并选择链接地址时,它变成了以下脚本
javascript:__doPostBack('LeaderBoard1$cmdCSV','')
Run Code Online (Sandbox Code Playgroud)
而不是让我访问 csv 文件的 url。
有没有办法解决这个问题。
我正在尝试使用以下代码通过 Puppeteer在https://moz.com/login上登录到Moz:
const puppeteer = require('puppeteer');
const creds = {
email: "myemail",
password: "mypassword"
};
(async () => {
const browser = await puppeteer.launch({
args: [
'--disable-web-security',
],
headless: false
});
const page = await browser.newPage();
await page.goto("https://moz.com/login");
await page.$eval("input[name=email]", (el, value) => el.value = value, creds.email);
await page.$eval("input[name=password]", (el, value) => el.value = value, creds.password);
await Promise.all([
page.$eval("input[type=submit]", elem => elem.click()),
page.waitForNavigation({ waitUntil: 'networkidle0' }),
]);
await browser.close();
})();
Run Code Online (Sandbox Code Playgroud)
我知道我传递的电子邮件和密码是正确的,因为我可以使用它们手动登录,但是当我运行上面的脚本时,我在表单上方收到“无效的电子邮件或密码”错误。
Chrome 中的 JS 控制台记录了两个错误:
无法加载资源:服务器无法加载资源:服务器与404状态响应()cs.moz.com/id?d_visid_ver=1.10.0&d_fieldgroup=A&mcorgid=2C702C1653CF9B460A490D4B%40AdobeOrg&mid=86471825972219878023490878783607186756&ts=1564059866100:1 …
我想抓取此页面中包含的所有数据。不幸的是,我只能提取前三行。
import requests
from bs4 import BeautifulSoup
response = requests.get("https://www.coingecko.com/fr/pièces/bitcoin#markets")
soup = BeautifulSoup(response.text, "html.parser")
My_table = soup.find("table",{"class":"table table-scrollable"})
My_table
data = []
rows = My_table.find_all('tr')
for row in rows:
cols = row.find_all('td')
cols = [ele.text.strip() for ele in cols]
data.append([ele for ele in cols if ele]) # Get rid of empty values
data
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助
我想从 Instagram 上抓取所有包含 #hashtag 的帖子
我从以下网址尝试过:https : //www.instagram.com/explore/tags/perfume/?__a=1
但它只提供一些帖子而不是每个帖子。
我已经使用 selenium 在 python 中编写了一个脚本来获取从网页遍历多个页面的不同作业的标题。当我运行脚本时,我可以注意到 selenium 无法打开该网页。但是,我可以在 Internet Explorer 或 Chrome 中手动使用该链接轻松查看该页面的内容。
网页链接 #如果看不到内容,请务必刷新页面
我试过:
from bs4 import BeautifulSoup
from selenium import webdriver
URL = 'https://www.alljobs.co.il/SearchResultsGuest.aspx?page=1&position=235,330,320,236,1541&type=&city=®ion='
with webdriver.Chrome() as driver:
driver.get(URL)
soup = BeautifulSoup(driver.page_source,'lxml')
while True:
for item in soup.select('[class="job-content-top"]'):
title = item.select_one('.job-content-top-title a[title')
print(title)
try:
next_page = driver.find_elemeny_by_css_selector('.jobs-paging-next > a').click()
soup = BeautifulSoup(driver.page_source,'lxml')
except Exception:
break
Run Code Online (Sandbox Code Playgroud)
我什至这样尝试过,但这也不起作用(从浏览器收集的 cookie):
from bs4 import BeautifulSoup
from selenium import webdriver
URL = 'https://www.alljobs.co.il/SearchResultsGuest.aspx?page=1&position=235,330,320,236,1541&type=&city=®ion='
cookie = "_ga=GA1.3.1765365490.1582505881; _gid=GA1.3.568643527.1582505881; _fbp=fb.2.1582505881473.1930545410; _hjid=619e3a88-ee5a-43ca-8a0b-e70b063dcf84; BlockerDisplay=; DiplayPopUpSalarySurvey=; OB-USER-TOKEN=390dca4f-08d0-4f54-bce5-00e7e6aa3e39; LPVID=dkY2EwOTNmZTA4YTM1MDI1; …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用请求模块在 python 中创建一个脚本,以从网站上抓取不同工作的标题。要解析不同工作的标题,我需要首先从该站点获得相关响应,以便我可以使用 BeautifulSoup 处理内容。但是,当我运行以下脚本时,我可以看到该脚本产生的乱码实际上不包含我要查找的标题。
网站链接( In case you don't see any data, make sure to refresh the page)
我试过:
import requests
from bs4 import BeautifulSoup
link = 'https://www.alljobs.co.il/SearchResultsGuest.aspx?'
query_string = {
'page': '1',
'position': '235',
'type': '',
'city': '',
'region': ''
}
with requests.Session() as s:
s.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36'
s.headers.update({"Referer":"https://www.alljobs.co.il/SearchResultsGuest.aspx?page=2&position=235&type=&city=®ion="})
res = s.get(link,params=query_string)
soup = BeautifulSoup(res.text,"lxml")
for item in soup.select(".job-content-top [class^='job-content-top-title'] a[title]"):
print(item.text)
Run Code Online (Sandbox Code Playgroud)
我什至这样试过:
import urllib.request …Run Code Online (Sandbox Code Playgroud) python beautifulsoup web-scraping python-3.x python-requests
我一直在尝试使用来自Pitchfork https://pitchfork.com/reviews/albums/us-girls-heavy-light/ 的rvest in r 来显示这首歌的评论评级。在这种情况下,它是 8.5。但不知何故我得到了这个:

这是我的代码
library(rvest)
library(dplyr)
library(RCurl)
library(tidyverse)
URL="https://pitchfork.com/reviews/albums/us-girls-heavy-light/"
webpage = read_html(URL)
cat("Review Rating")
webpage%>%
html_nodes("div span")%>%
html_text
Run Code Online (Sandbox Code Playgroud) 我是一个初学者,我正在开发一个代码来可视化冠状病毒在全球的传播,我想从GitHub 存储库(csse_covid_19_data)中提取 .csv 文件,其中每 2 天上传一个新的 .csv 文件。是否可以将最新的 csv 文件自动导入笔记本,而不是手动下载文件?
我试过抓取数据,但没有帮助
import requests
url = 'https://github.com/CSSEGISandData/COVID-19/blob/master/csse_covid_19_data/csse_covid_19_daily_reports/03-08-2020.csv'
response = requests.get(url)
print(response.text)
Run Code Online (Sandbox Code Playgroud) 几天前,当我运行它时,此代码工作正常:
from bs4 import BeautifulSoup
import datetime
import requests
def getWeekMostRead(date):
nonfiction_page = requests.get("https://www.amazon.com/charts/"+date.isoformat()+"/mostread/nonfiction")
content = "amazon"+date.isoformat()+"_nonfiction.html"
with open(content, "w", encoding="utf-8") as nf_file:
print(nonfiction_page.content, file=nf_file)
mostRead_nonfiction = BeautifulSoup(nonfiction_page.content, features="html.parser")
nonfiction = mostRead_nonfiction.find_all("div", class_="kc-horizontal-rank-card")
mostread = []
for books in nonfiction:
if books.find(class_="kc-rank-card-publisher") is None:
mostread.append((
books.find(class_="kc-rank-card-title").string.strip(),
books.find(class_="kc-rank-card-author").string.strip(),
"",
books.find(class_="numeric-star-data").small.string.strip()
))
else:
mostread.append((
books.find(class_="kc-rank-card-title").string.strip(),
books.find(class_="kc-rank-card-author").string.strip(),
books.find(class_="kc-rank-card-publisher").string.strip(),
books.find(class_="numeric-star-data").small.string.strip()
))
return mostread
mostread = []
date = datetime.date(2020,1,1)
while date >= datetime.date(2015,1,1):
print("Scraped data from "+date.isoformat())
mostread.extend(getWeekMostRead(date))
date -= datetime.timedelta(7)
print("Currently saving scraped …Run Code Online (Sandbox Code Playgroud) web-scraping ×10
python ×5
python-3.x ×3
html ×2
r ×2
data-science ×1
excel ×1
instagram ×1
node.js ×1
puppeteer ×1
rvest ×1
scrapy ×1
selenium ×1
vba ×1