我有功能做一些工作.代码应重复1.3亿次.
目前,我使用Crontab每1分钟运行一个python脚本.这需要太长的时间,我希望这个python脚本在第一次运行时运行并不断重复,直到工作结束.我想在2个任务之间休息10秒.我怎样才能做到这一点?
我知道如何获得一条线,但我不知道如何获得一个领域。例如,有一个表,有 id、title、content 字段。
ModelsExample.objects.filter(id = showid)# get one line.
Run Code Online (Sandbox Code Playgroud)
如何仅获取标题字段?
html看起来像这样:
<td class='Thistd'><a ><img /></a>Here is some text.</td>
Run Code Online (Sandbox Code Playgroud)
我只想得到字符串<td>.我不需要<a>...</a>.我怎样才能做到这一点?
我的代码:
from bs4 import BeautifulSoup
html = """<td class='Thistd'><a><img /></a>Here is some text.</td>"""
soup = BeautifulSoup(html)
tds = soup.findAll('td', {'class': 'Thistd'})
for td in tds:
print td
print '============='
Run Code Online (Sandbox Code Playgroud)
我得到的是 <td class='Thistd'><a ><img /></a>Here is some text.</td>
但我只是需要 Here is some text.