我想:
color:#333;)color:#333to更改color:#444).这样做有什么建议吗?
我在课堂上有这个方法
class CatList:
lista = codecs.open('googlecat.txt', 'r', encoding='utf-8').read()
soup = BeautifulSoup(lista)
# parse the list through BeautifulSoup
def parseList(tag):
if tag.name == 'ul':
return [parseList(item)
for item in tag.findAll('li', recursive=False)]
elif tag.name == 'li':
if tag.ul is None:
return tag.text
else:
return (tag.contents[0].string.strip(), parseList(tag.ul))
Run Code Online (Sandbox Code Playgroud)
但是当我尝试这样称呼时:
myCL = CatList()
myList = myCL.parseList(myCL.soup.ul)
Run Code Online (Sandbox Code Playgroud)
我有以下错误:
parseList() takes exactly 1 argument (2 given)
Run Code Online (Sandbox Code Playgroud)
我试图将self添加为方法的参数,但是当我这样做时,我得到的错误如下:
global name 'parseList' is not defined
Run Code Online (Sandbox Code Playgroud)
我不太清楚这实际上是如何运作的.
任何提示?
谢谢
我正在尝试从Google Image搜索中获取特定查询的图像.但我下载的页面没有图片,它将我重定向到谷歌的原始页面.这是我的代码:
AGENT_ID = "Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"
GOOGLE_URL = "https://www.google.com/images?source=hp&q={0}"
_myGooglePage = ""
def scrape(self, theQuery) :
self._myGooglePage = subprocess.check_output(["curl", "-L", "-A", self.AGENT_ID, self.GOOGLE_URL.format(urllib.quote(theQuery))], stderr=subprocess.STDOUT)
print self.GOOGLE_URL.format(urllib.quote(theQuery))
print self._myGooglePage
f = open('./../../googleimages.html', 'w')
f.write(self._myGooglePage)
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
谢谢
我开发了一个小书签,它工作得很好,直到chrome最后更新.
现在它在Facebook上点击它时会运行"不安全的内容",它甚至不会在Twitter上启动.
我想知道锄头,以避免"不安全的内容"和铬块阻止.
这是代码:
书签
if (typeof jQuery === "undefined") {
var script_tag = document.createElement('script');
script_tag.setAttribute("type","text/javascript");
script_tag.setAttribute("src","http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
script_tag.onload = function() { $.getScript('http://www.silviolorusso.com/scrolltv/scrolltv.js',function(){main();}); };
script_tag.onreadystatechange = function () {
if (this.readyState == 'complete' || this.readyState == 'loaded') $.getScript('http://www.silviolorusso.com/scrolltv/scrolltv.js',function(){main();});
};
document.getElementsByTagName("head")[0].appendChild(script_tag);
} else {
$.getScript('http://www.silviolorusso.com/scrolltv/scrolltv.js',function(){
main();
});
}
Run Code Online (Sandbox Code Playgroud)
注入js
var status = 0;
$bottom = 100;
$position = 0;
function scrollTV() {
if ( ($(document).scrollTop() + $(window).height() - 500 ) >= $position ) {
$position = $position + 50;
$('html, …Run Code Online (Sandbox Code Playgroud) 我试过这个,但它不起作用
return re.sub('([^)]*)','', myResultStats.text)
Run Code Online (Sandbox Code Playgroud)
建议?
谢谢
我有这个HTML结构:
<div>
<table>
<tbody>
<tr>
<td>stuff</td>
</tr>
<tr>
<td>
<div>The content I want</div>
</td>
</tr>
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
如何获取"我想要的内容"并删除所有html标签?
谢谢
我们有一个python脚本,每天将邮件发送到xml地址列表.这些邮件始终被Gmail标记为垃圾邮件.这是代码:
email_body = '<html><body><div style="text-align: center; font-family: serif; font-size: 15px;"><br/><br/>@<br/><br/>' + text_splited[i] + '<br/><br/>@<br/><br/><a href="http://anemailstory.net/"><i>Tr@ces</i></a><br/><br/> - <br/><br/><a href="http://anemailstory.net/unsubscribe.html">unsubscribe</a><br/><br/></div></body></html>'
#text corresponding to that subcription date
# email
msg = MIMEMultipart('alternative') #Create Multipart msg (allows html)
msg['To'] = email.utils.formataddr(('Recipient', 'readers@traces.net'))
msg['From'] = email.utils.formataddr(('Traces', 'traces@anemailstory.net'))
msg['Subject'] = 'Tr@ces - Part #' + str((i+2))
part_html = MIMEText(email_body, 'html')
msg.attach(part_html)
server = smtplib.SMTP('localhost')
server.set_debuglevel(False) # show communication with the server
try:
server.sendmail('traces@noreply.net', email_addrs, msg.as_string())
finally:
server.quit()
Run Code Online (Sandbox Code Playgroud)
这是生成的电子邮件:
Return-path: <traces@noreply.net>
Envelope-to: mimmo@mimmo.com
Delivery-date: Wed, 25 Apr …Run Code Online (Sandbox Code Playgroud) 我正在尝试开发一个插件,当单击浏览器操作时,该插件会影响浏览器中的每个选项卡和窗口。
这是我目前拥有的代码:
function updateIcon() {
chrome.browserAction.setIcon({path:current});
if (current == "icon-left.png")
{
current = "icon-right.png";
chrome.tabs.executeScript(null, {file: "cursor.js"});
}
else
{
current = "icon-left.png";
chrome.tabs.reload(null);
}
}
Run Code Online (Sandbox Code Playgroud)
有什么建议吗?
谢谢
我有一个具有以下结构的数据库:
id msg
1 'Hello'
2 'Bye'
Run Code Online (Sandbox Code Playgroud)
我需要获得"id"的"msg"值.
这是我的尝试:
$text = mysql_query("SELECT msg FROM text WHERE text (id) ='$msg_num'");
Run Code Online (Sandbox Code Playgroud)
但它不起作用:(你有建议吗?谢谢
我正在尝试通过Javascript更改页面中所有链接的样式.
我试过这两个但没有成功:
document.links.style.cursor = "wait";
document.getElementsByTagName(a).style.cursor = "wait";
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?