我正在尝试为自己创建一个脚本,以便在一些分类网站上使用并从 cl 开始,我正在使用flask web 框架和robobrowser,但进展并不顺利。
目标它将采用我的预设值并将它们放入该分类网站的字段中。这似乎不是一个困难的概念,但是在阅读了 5 个小时的在线不同代码和反复试验后,我记得最好的开发人员在堆栈中......
我应该告诉你我是 Python 的新手,还有很多东西要学,所以任何帮助都将不胜感激。
我得到的错误是: assert isinstance(form, 'str') TypeError: isinstance() arg 2 must be a type or tuple of types
但我不知道如何解决这个问题并且完全迷失了。帮助!!!提前致谢
# autosubmit to site
from flask import Flask
from robobrowser import RoboBrowser
app = Flask(__name__)
@app.route('/', methods = ['GET', 'POST'])
class My_RoboBrowser(RoboBrowser):
def __init__(self, auth=None, parser=None, headers=None, user_agent=None, history=True):
RoboBrowser.__init__(self, parser=None, user_agent=None, history=True)
def Open(self, vURL, vVerify=True):
response = self.session.get(vURL, verify=vVerify)
self._update_state(response)
browser = My_RoboBrowser(RoboBrowser, "html.parser");
urlL = 'https://accounts.craigslist.org/login'
browser.Open(urlL)
form = browser.get_form(id='login')
assert isinstance(form, 'str')
form['username'] = 'username'
form['password'] = 'password'
browser.submit_form(form)
urlQ = 'https://post.craigslist.org/k/qGDv7K4q5RGD0B5ZEBgXOQ/GLzgd?s=edit'
browser.open(urlQ)
#Question_Tag = browser.find_all(class_="not_answered")[0]
#ID = Question_Tag.get('data-qid')
#Get the form to fill out
Form = browser.get_form(id='formpost')
Form['PostingTitle'].value = 'Create this advertise ment in py'
Form['Postal_code'].value = ['10543']
Form['PostingBody'].value = 'TOGETHER WE INNOVATE Stress free communication with developers that are in the United States. We pride ourselves in bringing your web and app ideas to life and keeping your data secured'
browser.submit_form(Form)
if __name__ == "__main__":
app.run()