xlzd

xlzd

签名
V2EX member #108641, joined on 2015-04-01 23:21:03 +08:00
个人简介
Per xlzd's settings, the topics list is hidden
Deals info, including closed deals, is not hidden
xlzd's recent replies
@allencode 看到你在 GitHub 的仓库啦,其实关键词可以考虑从服务器下发,不要写死在代码中。
Apr 11, 2016
Replied to a topic by omg21 Python 用 BeautifulSoup4 怎样取出全部链接的 text ?
list_a, list_a_text = (lambda l: ([_['href'] for _ in l], [_.getText() for _ in l]))(getattr(__import__('bs4'), 'BeautifulSoup')(open('tmp1.txt'), 'lxml').find_all('a'))

上面的代码即可取出 tmp1.txt 中的所有链接放到 list_a 中,并将链接中的文本放到 list_a_text 中。
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3018 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 07:58 · PVG 15:58 · LAX 00:58 · JFK 03:58
♥ Do have faith in what you're doing.