Home > other >  Consult: an error in the execution procedures, couldn't find where is the problem?
Consult: an error in the execution procedures, couldn't find where is the problem?

Time:09-26

The import requests
The from bs4 import BeautifulSoup
The import bs4
The from rest_framework. Response import response

Def getHTMLText (url) : # input needed for the url of the information, the output is the content of the url
Try:
R=requests. Get (url, timeout=30)
R.r aise_for_status ()
R.e ncoding=of state Richard armitage pparent_encoding
Return r.t ext
Except:
Return ""



Def fillUnivList (ulist, HTML) : # HTML page to be included in the list ulist
Soup=BeautifulSoup (HTML, '. The HTML parser)
For the tr in soup. The find (' tbody.) children:
If isinstance (tr, bs4. Element. The Tag) :
TDS=tr # (" td ") of the tr labels td do query
Ulist. Append ([TDS [0], string, TDS [1]. The string, TDS [3]. The string])


Def printUnivList (ulist, num) : # to print out the elements in the list
TPLT='{0: ^ 10} \ t {1: {3} ^ 10} \ t {2: ^ 10}'
Print (TPLT. The format (' no ', 'school name', 'total score, CRH (12288)))
For I in range (num) :
U=ulist [I]
Print (TPLT. The format (u [0], u [1], u [2], CRH (12288)))


Def the main () : # main function
Uinfo=[]
Url='http://www.zuihaodaxue.com/zuihaodaxuepaiming2018.html'
HTML=getHTMLText (url)
FillUnivList (uinfo, HTML)
PrintUnivList (uinfo, 20)


The main ()


Execution error: TypeError: __init__ () takes a positional argument but 2 were given
Couldn't find where is problem! ?
  • Related