1

I am attempting to write a bot in pyppeteer. What I am attempting to do with my code is send a POST request to a website with specific postData

        Add_url = f"https://www.website.com/shop/{productID}/add.json"
        await page.setExtraHTTPHeaders(headers=headers)
        await page.setRequestInterception(True)
        page.o
        atc_post = await Request.continue_(self,overrides={'url':Add_url, 'method':'POST','postData':data})
        print(atc_post.json())

This is my current output from my terminal:

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyppeteer/network_manager.py", line 447, in continue_

if not self._allowInterception:

AttributeError: 'Bot' object has no attribute '_allowInterception'

If anybody could help I would greatly appreciate it.

Floaters
  • 33
  • 1
  • 4

1 Answers1

0

Request.continue_ is only valid after interception for example:

async def intercept (req):
    print (req.headers)
    await req.continue_ ()
    pass

async def main():
    browser = await launch()
    page = await browser.newPage()
    await page.setRequestInterception(True)
    page.on ('request', lambda req: asyncio.ensure_future (intercept (req)))
    await page.goto('https://www.exemple.com') 
    await browser.close()
    return html

html=asyncio.get_event_loop().run_until_complete(main())

guilloptero
  • 1,583
  • 1
  • 10
  • 6