Pinterest的一个简单的Python客户机,支持用户与Pinterest交互,例如简单浏览器。
pinterest-client的Python项目详细描述
Pinterest客户端
pinterest的一个简单python客户机,支持用户与 例如简单的浏览器。
支持操作:登录、pin、保存pin、删除pin、板、创建 板,删除板,跟踪板,跟踪用户,评论,搜索管脚, 搜索用户,搜索板。
安装
This package is in pypi所以你可以 使用pip命令轻松安装:
pip install pinterest-client
或者从源代码安装,如果您使用 命令:
python setup.py install
用法
安装成功后,可以初始化新的pinterest 对象:
frompinterestimportPinterestpinterest=Pinterest(username_or_email='your_username_or_email',password='your_password')
< H3>用代理< EH3>
如果需要使用代理,可以将代理参数传递给构造函数
frompinterestimportPinterestproxies={'http':'http://10.10.1.10:3128','https':'http://10.10.1.10:1080',}pinterest=Pinterest(username_or_email='your_username_or_email',password='your_password',proxies=proxies)
自定义用户代理
您还可以为每个pinterest客户机使用自定义用户代理字符串 对象
frompinterestimportPinterestagent_string='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0'pinterest=Pinterest(username_or_email='your_username_or_email',password='your_password',agent_string=agent_string)
操作
frompinterestimportPinterestpinterest=Pinterest(username_or_email='your_username_or_email',password='your_password')# Login to pinterest site, if 'ok' return True otherwise return Falselogged_in=pinterest.login()# Get all boards of logged in userboards=pinterest.boards()# Create new board, it also return new board data if creation was successfulpinterest.create_board(name='Board name',description='Description')# Follow a boardpinterest.follow_board(board_id='657384945546806337',board_url='/cvhautt/animal/')# Follow a userpinterest.follow_user(user_id='657385014266199005',username='cvhautt')# Create pin from an image urlpin=pinterest.pin(board_id='657384945546806337',image_url='your_image_url',description='your_description (*optional)',link='your_link (*optional)')# Create pin by uploading an image from your computeruploaded_pin=pinterest.upload_pin(board_id='657384945546806337',image_file='full_path_to_your_image',description='your_description (*optional)')# Save a pin to your board (known as Save button on Pinterest site)pinterest.repin(board_id='657385014266199005',pin_id='pin_id')# Delete a pinpinterest.delete_pin(pin_id='your_pin_id')# Comment on a pincmt=pinterest.comment(pin_id='your_pin_id',text='your_comment_text')# Delete a comment from pinpinterest.delete_comment(pin_id='your_pin_id',comment_id='your_comment_id')# Invite a person to join to your boardpinterest.invite(board_id='your_board_id',board_url='your_board_url',user_id='user_id')# Search data on Pinterest siteboards=pinterest.search_boards(query='Some query')pins=pinterest.search_pins(query='Some query')users=pinterest.search_users(query='Some query')# You can also get next page from search result by passing next_page=True to search operations above.# Exp:boards=pinterest.search_boards(query='Some query',next_page=True)pins=pinterest.search_pins(query='Some query',next_page=True)