0

Hi I am getting the error get() missing 1 required positional argument: 'url' I am using HTMLsession for importing the data from a website. sharing the code below. '''

from requests_html import HTMLSession
from bs4 import BeautifulSoup
import requests 
session=HTMLSession
url="https://pureportal.coventry.ac.uk/en/organisations/coventry-university/publications/"
def data(url):
  r=session.get(url)
  r.html.render(sleep=1)
  soup=BeautifulSoup(r.html.html,"html.parser")
  return soup
def Allpage(soup):
    page=soup.find("li",{"class":"step"})
    if not page.find("li",{"class":"next"}):
        url="https://pureportal.coventry.ac.uk/" + str(page.find("li",{"class":"step"})).find("a")["href"]
        return url
    else:
        return
while True:
    getdata=data(url)
    url=Allpage(getdata)
    print(URL)

'''

TypeError: get() missing 1 required positional argument: 'url'

2 Answers 2

1

session should be instance of HTMLSession, consider that

from requests_html import HTMLSession
session = HTMLSession
session.get("http://www.example.com")

gives TypeError: get() missing 1 required positional argument: 'url' whilst

from requests_html import HTMLSession
session = HTMLSession()
session.get("http://www.example.com")

works without errors (last line returns <Response [200]>)

Sign up to request clarification or add additional context in comments.

Comments

0

You forgot to instantiate HTMLSession, so the 'get' method acts strangely. Just change your session declaration to :

session=HTMLSession()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.