我正在尝试使用 puppeteer 在 chromium 中加载 axios,代码如下:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless:false})
const page = await browser.newPage()
await page.goto('https://httpbin.org/get')
await page.evaluate(async () => {
var script = document.createElement('script');
script.setAttribute('src','https://unpkg.com/axios@0.21.0/dist/axios.min.js');
document.head.appendChild(script);
var r = await axios.get('https://httpbin.org/get')
console.log(r)
})
})()
Run Code Online (Sandbox Code Playgroud)
但是当我尝试执行时axios.get它会返回Evaluation failed: ReferenceError: axios is not defined. 这里有什么问题?
如何在 Puppeteer 中禁用图像/CSS?我看过这个教程https://www.scrapehero.com/how-to-increase-web-scraping-speed-using-puppeteer/ 但我不知道如何将它翻译成 Python
基本上我有这两个列表
listone = ['a', 'b', 'c', 'd', 'e', 'f', 'j']
listtwo = ['1', '2', '3']
Run Code Online (Sandbox Code Playgroud)
我想同步迭代两个列表,并且每当最短列表结束时(在本例中为 listtwo)再次重新启动,直到 listone 完成。例子:
a 1
b 2
c 3
d 1
e 2
f 3
j 1
Run Code Online (Sandbox Code Playgroud)
像这样。