python 的问题

2016-10-20 18:02:34 +08:00
 182247236
码如下:
PID = 'lKGXIQa'

GetPlayer = "http://213432.com/liveforapp.php?cid={cid}&appid={appid}" .format(cid=PID,appid="01")

from urllib.request import urlopen
from pprint import pprint
from bs4 import BeautifulSoup

url = urlopen(GetPlayer)
print(url.read())
这样我就能得出
b'<a href="http://213432.com/live.php?token=dH0xNDc2XTU3NDc2JmM9bEtHWElRYSZhPTAxJnY9ZWJhZGY|">http://213432com/live.php?token=dH0xNDc2XTU3NDc2JmM9bEtHWElRYSZhPTAxJnY9ZWJhZGY|</a>'
问题是我只想得出 url ,因为待会要用...html 标签什么的没用,网上查了查好多没用的资料 TT ,有什么办法吗?
1147 次点击
所在节点    问与答
2 条回复
182247236
2016-10-20 18:04:54 +08:00
我之前是这么写的
PID = 'lKGXIQa'

GetPlayer = "http://12345.cutv.com/liveforapp.php?cid=%s" %PID +'&appid=S01'

from urllib.request import urlopen
from pprint import pprint
from bs4 import BeautifulSoup



html = urlopen(GetPlayer)

bs_obj = BeautifulSoup(html,'html.parser')

for link in bs_obj.findAll('a'):
print(link.get_text())
这么可以得出我需要的 url ,可是我觉得太复杂不好,想改简单点
182247236
2016-10-20 22:55:30 +08:00
要沉吗 TT

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/314211

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX