您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何使用python登录网站?

如何使用python登录网站?

尝试机械化

import mechanize
br=mechanize.Browser()
br.open('https://mog.com/hp/sign_in')
br.select_form(nr=0) 
br['user[login]']= your_login
br['user[password]']= your_password
br.submit()
br.retrieve('http://mog.com/my_mog/playlists','playlist.html')

获取您的链接,您可以添加以下内容

for link in br.links():
    print link.url, link.text

或者,从开始playlist.html,您可以使用Beautifulsoup和regex:

from BeautifulSoup import BeautifulSoup
import re
soup = BeautifulSoup(file('playlist.html').read())
for link in soup.findAll('a', attrs={'href': re.compile("your matching re")}):
    print link.get('href')
python 2022/1/1 18:33:53 有200人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶