Oct-12-2019, 05:47 PM
I have two modules only.
the first one - is the main programm, which is using functions from the second module.
The second module consists from functions only
Here is the first module
the first one - is the main programm, which is using functions from the second module.
The second module consists from functions only
Here is the first module
import requests from bs4 import BeautifulSoup import sys sys.path.append("E:\\Python\\Learning\\Parce_functions") spisok = [] _tmpvar = "" import F_Hydac_POST _name_element = "pi3111" spisok = F_Hydac_POST.start_parce(_name_element) print("Here is the Hydac list", spisok)here is the second module
def fg_list_bot(_name_element, _output_file): _url = "https://www.hydac.com/de-de/nc/service/online-tools/betterfit.html?tx_hybetterfit_pi2%5Baction%5D=search&tx_hybetterfit_pi2%5Bcontroller%5D=Search&cHash=c662ac5f5387b650059f2ede4c291cec" # THis line produces an error message s = requests.Session() _headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0"} _data = {"tx_hybetterfit_pi2[query]": _name_element} r = requests.post(_url, data=_data, headers = _headers) with open(_output_file, "w") as f: f.write(r.text) print(r.status_code) return(r.text) def start_parce(_name_element): _output_file = "IDLE_HYDAC.html" _tmpvar = fg_list_bot(_name_element, _output_file)Here is the error message
================= RESTART: E:\Python\Learning\start_parce.py ================= Traceback (most recent call last): File "E:\Python\Learning\start_parce.py", line 10, in <module> spisok = F_Hydac_POST.start_parce(_name_element) File "E:\Python\Learning\Parce_functions\F_Hydac_POST.py", line 81, in start_parce _tmpvar = fg_list_bot(_name_element, _output_file) File "E:\Python\Learning\Parce_functions\F_Hydac_POST.py", line 5, in fg_list_bot s = requests.Session() NameError: name 'requests' is not defined