返回func(* args,** kwargs)ValueError:读取已关闭的文件

时间:2018-08-02 05:49:28

标签: python python-3.5 valueerror

from urllib.request import FancyURLopener
from bs4 import BeautifulSoup

class MyOpener(FancyURLopener):
    version = 'My new User-Agent'

myopener = MyOpener()

url3 = ("http://www.zamaninternational.org/news.php?n=71' /*!UNION*/ /*!SELECT*/ 1,2,3,4,5,6,7,8,9,10,11,12,13,14--+")

url_oku3 = myopener.open(url3)
soup3 = BeautifulSoup(url_oku3, 'html.parser')
Traceback (most recent call last):
  File "untitled.py", line 13, in <module>
    soup3 = BeautifulSoup(url_oku3, 'html.parser')
  File "C:\Python37\site-packages\bs4\__init__.py", line 245, in __init__
    markup = markup.read()
  File "C:\Python37\lib\tempfile.py", line 481, in func_wrapper
    return func(*args, **kwargs)
ValueError: read of closed file

1 个答案:

答案 0 :(得分:1)

URL必须简单地为"http://www.zamaninternational.org/news.php?n=71"。是该行其余部分中的垃圾损害了开瓶器。

有趣的是,"' /*!UNION*/ /*!SELEC"的打开器仍然可以,但随后的任何操作都会使它窒息。