Python中文
首页
教程
问答
标签
搜索
登录
注册
如何从Python scrip捕获Curl的输出
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我想找到关于使用curl的网页的信息,但是在Python中,到目前为止我有:</p> <pre><code>os.system("curl --head www.google.com") </code></pre> <p>如果我查一下,它会打印出来:</p> <pre><code>HTTP/1.1 200 OK Date: Sun, 15 Apr 2012 00:50:13 GMT Expires: -1 Cache-Control: private, max-age=0 Content-Type: text/html; charset=ISO-8859-1 Set-Cookie: PREF=ID=3e39ad65c9fa03f3:FF=0:TM=1334451013:LM=1334451013:S=IyFnmKZh0Ck4xfJ4; expires=Tue, 15-Apr-2014 00:50:13 GMT; path=/; domain=.google.com Set-Cookie: NID=58=Giz8e5-6p4cDNmx9j9QLwCbqhRksc907LDDO6WYeeV-hRbugTLTLvyjswf6Vk1xd6FPAGi8VOPaJVXm14TBm-0Seu1_331zS6gPHfFp4u4rRkXtSR9Un0hg-smEqByZO; expires=Mon, 15-Oct-2012 00:50:13 GMT; path=/; domain=.google.com; HttpOnly P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." Server: gws X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN Transfer-Encoding: chunked </code></pre> <p>我想做的是,能够使用regex匹配其中的200(我不需要帮助),但是,我找不到方法将上面的所有文本转换为字符串。我该怎么做? 我试过:<code>info = os.system("curl --head www.google.com")</code>但是<code>info</code>只是<code>0</code>。</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>不知为什么。。。我需要使用curl(没有pycurl,httplib2…),也许这可以帮助某些人:</p> <pre><code>import os result = os.popen("curl http://google.es").read() print result </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何将python输出重定向到python控制台和Windows中的文本文件
6 回答
如何将Python运行时嵌入运行在Windows上的R包中
4 回答
如何将python进程作为另一个Windows us运行
7 回答
如何将Python进程的输出用Python管道传输?
5 回答
如何将Python进程的输出重定向到Rust进程?
3 回答
如何将python连接到Azure云并创建Azure数据工厂
4 回答
如何将Python连接到Db2
4 回答
如何将python连接到IBMDB2?
9 回答
如何将Python连接到microsoftaccess数据库文件?
1 回答
如何将python连接到MySQL服务器
3 回答
如何将Python连接到Node.js?
9 回答
如何将python连接到Oracle Application Express
9 回答
如何将Python连接到PostgreSQL
5 回答
如何将Python连接到Postgres服务器?
7 回答
如何将Python连接到SAS Enterprise Guide(EG)服务器
8 回答
如何将Python连接到Spark会话并保持RDDs的Ali
5 回答
如何将python连接到sqlite3并在上填充多行
9 回答
如何将python连接到使用docker运行的cassandra
9 回答
如何将python退格应用于字符串
5 回答
如何将python逻辑应用到tkinter GUI中?这是一个简单的GET请求程序
6 回答