尝试制作一个python脚本,可以从保存的pastebin输出页面上的pastebin的RAW Paste Data部分中删除。但是我遇到了Python属性错误的问题,关于NoneType没有对象属性'text',我在项目中使用了BeautifulSoup中的库。我尝试使用QuestionEntity questionEntity = this.questionRepository.getById(questionId);
for(AnswerEntity answer : questionEntity .getAnswers()) {
if(answer.getId().equals(answerId) [
answerEntity = answer;
}
}
answerEntity.setVotes(...);
安装spider-egg
,因此我也可以使用它,但是从服务器下载软件包时出现问题。
我需要能够从RAW粘贴数据部分抓取不同的多行,并将它们打印出来给我。
pip install
从pastebin页面我有RAW粘贴数据部分的类元素名称;
first_string = raw_box.text.strip()
second_string = raw_box2.text.strip()
取类名<textarea id="paste_code" class="paste_code" name="paste_code" onkeydown="return catchTab(this,event)">
然后我有了这个
paste_code
我认为应该是它,但显然不是,因为我得到了我之前提到的错误。解析已剥离的数据后,我需要能够在打印完所有内容后将其重定向到文件中。我也想尝试使这个python3兼容,但我认为这需要更多的工作,因为python 2.7.12和3.5.2之间存在很多差异。
答案 0 :(得分:0)
以下方法应该有助于您入门:
/usr/share/bash-completion/completions/sudo
此示例应显示:
import requests
from bs4 import BeautifulSoup
r = requests.get('https://pastebin.com/hGeHMBQf')
soup = BeautifulSoup(r.text, "html.parser")
raw = soup.find('textarea', id='paste_code').text
print raw