小编jia*_* Ma的帖子

每10秒运行一次Python脚本

我有功能做一些工作.代码应重复1.3亿次.

目前,我使用Crontab每1分钟运行一个python脚本.这需要太长的时间,我希望这个python脚本在第一次运行时运行并不断重复,直到工作结束.我想在2个任务之间休息10秒.我怎样才能做到这一点?

python

5
推荐指数
2
解决办法
2万
查看次数

Django 模型如何获得一个字段?

我知道如何获得一条线,但我不知道如何获得一个领域。例如,有一个表,有 id、title、content 字段。

ModelsExample.objects.filter(id = showid)# get one line.
Run Code Online (Sandbox Code Playgroud)

如何仅获取标题字段?

django

4
推荐指数
1
解决办法
4570
查看次数

如何用beautifulsoup4提取HTML?

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.

python beautifulsoup

1
推荐指数
1
解决办法
68
查看次数

标签 统计

python ×2

beautifulsoup ×1

django ×1