草庐IT

media-soup

全部标签

Python,如何将状态/update_with_media 发布到 Twitter?

我能够使用Python成功发布状态更新(tweet):importurllibimportoauth2asoauthtoken=oauth.Token(access_token,access_token_secret)consumer=oauth.Consumer(consumer_key,consumer_secret)client=oauth.Client(consumer,token)data={'status':'helloworld'}request_uri='https://api.twitter.com/1/statuses/update.json'resp,conten

python - 用 Beautiful Soup 提取 href

我使用此代码来访问我的链接:links=soup.find("span",{"class":"hsmall"})links.findNextSiblings('a')forlinkinlinks:printlink['href']printlink.string链接没有ID或类或其他任何东西,它只是一个带有href属性的经典链接。我的脚本的响应是:printlink['href']TypeError:stringindicesmustbeintegers你能帮我获取href值吗?谢谢! 最佳答案 链接仍然指的是你的soup.find

python - 如何使用 Beautiful Soup 提取 <script> 标签中的字符串?

在给定的.html页面中,我有一个这样的脚本标记:jQuery(window).load(function(){setTimeout(function(){jQuery("input[name=Email]").val("name@email.com");},1000);});如何使用BeautifulSoup提取电子邮件地址? 最佳答案 向@Bob'sanswer添加更多信息并假设您还需要在HTML中找到script标签,其中可能有其他script标签。我们的想法是定义一个正则表达式,用于locatingtheelementwit

python - Django:MEDIA_URL 返回找不到页面

settings.py#-*-coding:utf-8-*-#Djangosettingsforbasicpinaxproject.importos.pathimportposixpathPROJECT_ROOT=os.path.abspath(os.path.dirname(__file__))DEBUG=TrueTEMPLATE_DEBUG=DEBUG#tellsPinaxtoservemediathroughthestaticfilesapp.SERVE_MEDIA=DEBUG#django-compressoristurnedoffbydefaultduetodeploymen

python - Django Admin Media 前缀 URL 问题

我有以下文件夹结构src\BAT\templates\admin\base.htmlsrc\BAT\media\base.csssrc\BAT\media\admin-media\base.css设置.pyMEDIA_ROOT=os.path.join(APP_DIR,'media')MEDIA_URL='/media/'ADMIN_MEDIA_PREFIX='/admin-media/'TEMPLATE_DIRS=(os.path.join(APP_DIR,'templates'))INSTALLED_APPS=('django.contrib.auth','django.contr

python - 如果我知道该元素或类的 ID,如何在某些 HTML 元素中使用 Beautiful Soup 设置值?

如果我知道某个HTML元素或类的ID,如何在某些元素中使用BeautifulSoup设置值?比如我有>我想设置文本RESTORE...就像RESTORE.... 最佳答案 使用find()搜索id=test找到您要修改的标签。然后:BeautifulSoupDocumentation-"Modifyingthetree"Modifying.stringIfyousetatag’s.stringattribute,thetag’scontentsarereplacedwiththestringyougive:markup='Ilink

python - Beautiful Soup Select 与 Find_all 数据类型

我是网络抓取的新手,似乎有两种方法可以收集我正在寻找的所有html数据。option_1=soup.find_all('div',class_='p')option_2=soup.select('div.p')我看到option_1返回类'bs4.element.ResultSet'并且option_2返回类'list'我仍然可以使用for循环遍历option_1,所以有什么区别:选择并查找所有'list'和bs4.element.ResultSet 最佳答案 您应该找到第一个问题的答案here(在评论中由t-m-adam链接)。关

python - Beautiful Soup 和 Unicode 问题

我正在使用BeautifulSoup来解析一些网页。偶尔我会遇到如下“unicodehell”错误:查看TheAtlantic.com上这篇文章的来源[http://www.theatlantic.com/education/archive/2013/10/why-are-hundreds-of-harvard-students-studying-ancient-chinese-philosophy/280356/]我们在og:description元属性中看到了这一点:当BeautifulSoup解析它时,我看到了这个:>>>printrepr(description)u'Thepr

python - 需要一种使用 Python 从 Zune 和 Windows Media Player 中检索当前播放歌曲的方法

我的一个应用程序从众多音乐播放器中检索当前播放的歌曲。但是,我在实现Zune和WindowsMediaPlayer时遇到了很大的麻烦。我在这个主题上做了很多谷歌搜索,不幸的是,它只会让我越来越困惑。我通常会为我的其他应用程序做什么:每4秒遍历所有打开的窗口获取所有窗口的标题检查模式的标题(即,"-Spotify")如果它在那里,调整输出的标题。WMP标题中没有当前播放的歌曲。Zune确实如此,但它每隔几秒就会在标题、专辑和艺术家之间轮换一次。尽管有可能,但使用我当前的方法进行跟踪非常不可靠。Windows媒体播放器我还尝试将COM组件用于windows媒体播放器。importwin32

python - 使用 Beautiful Soup 保存实体进行抓取

我想从网上抓取一张表格并保留 实体完好无损,以便我以后可以重新发布为HTML。BeautifulSoup似乎正在将这些转换为空格。示例:frombs4importBeautifulSouphtml=""html+=" hello "html+=""soup=BeautifulSoup(html)table=soup.find_all('table')[0]row=table.find_all('tr')[0]cell=row.find_all('td')[0]printcell观察结果: hello 要求的结果: hello