当我从代码中的URL解析xml时,我收到以下错误.我不会发布XML,因为它很大.链接在下面的代码中.
错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-70-77e5e1b79ccc> in <module>()
11
12 for child in root.iter('Materia'):
---> 13 if not child.find('EmentaMateria').text is None:
14 ementa = child.find('EmentaMateria').text
15
AttributeError: 'NoneType' object has no attribute 'text'
Run Code Online (Sandbox Code Playgroud)
我的代码:
url = 'http://legis.senado.leg.br/dadosabertos/senador/4988/autorias'
import requests
from xml.etree import ElementTree
response = requests.get(url, stream=True)
response.raw.decode_content = True
tree = ElementTree.parse(response.raw)
root = tree.getroot()
for child in root.iter('Materia'):
if child.find('EmentaMateria').text is not None:
ementa = child.find('EmentaMateria').text
for child_IdMateria in child.findall('IdentificacaoMateria'):
anoMateria = child_IdMateria.find('AnoMateria').text
materia …
Run Code Online (Sandbox Code Playgroud) 出于某种原因,iOS 模拟器停止工作。我可以打开 iOS 模拟器,但 Android Studio 无法识别它。我已经尝试通过终端运行,但它说not supported devices connected
.
当我运行flutter doctor
它返回:
Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.12.6 16G2136, locale pt-US)
[?] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[!] Xcode - develop for iOS and macOS (Xcode 9.2)
? Flutter requires a minimum Xcode version of 11.0.0.
Download the latest version or update via the Mac App …
Run Code Online (Sandbox Code Playgroud) 我制作了一个在我的计算机上运行良好的 node.js 网络抓取代码,但是,当我部署到运行 Debian 的 Google Cloud VM 实例时,它会返回特定网站的超时错误。我已经为 puppeteer 尝试了许多不同的设置,但似乎都不起作用。我相信当我从谷歌云服务器运行时,我试图抓取的网站会阻止我的代码,但当我从我的计算机运行时不会。抓取部分在我的电脑上运行良好。Puppeteer 找到 HTML 标签并检索信息。
const puppeteer = require('puppeteer');
const GoogleSpreadsheet = require('google-spreadsheet');
const { promisify } = require('util');
const credentials = require('./credentials.json');
async function main(){
const scrapCopasa = await scrapCopasaFunction();
console.log('Done!')
}
async function scrapCopasaFunction() {
const browser = await puppeteer.launch({
args: ['--no-sandbox'],
});
const page = await browser.newPage();
//await page.setDefaultNavigationTimeout(0);
//await page.setViewport({width: 1366, height: 768});
await page.setUserAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36');
await page.goto('http://www.copasa.com.br/wps/portal/internet/abastecimento-de-agua/nivel-dos-reservatorios');
//await …
Run Code Online (Sandbox Code Playgroud) javascript node.js web-scraping google-cloud-platform puppeteer
flutter ×1
ios ×1
javascript ×1
node.js ×1
puppeteer ×1
python ×1
web-scraping ×1
xcode ×1
xml ×1
xml-parsing ×1