fofapro / fofa-py

fofa pro的sdk,python语言版本
MIT License
150 stars 27 forks source link

SyntaxError: multiple exception types must be parenthesized #7

Closed SirKnightV closed 1 year ago

SirKnightV commented 2 years ago

hello, there, my steps got the next,

pip install fofa
Defaulting to user installation because normal site-packages is not writeable
Collecting fofa
  Downloading FOFA-1.0.2.tar.gz (1.6 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for fofa, since package 'wheel' is not installed.
Installing collected packages: fofa
  Running setup.py install for fofa ... done
Successfully installed fofa-1.0.2

So Later i write a python file for test the search (got the same as give a example here)

# -*- coding: utf-8 -*-
import fofa

if __name__ == "__main__":
    email, key = ('myemail', 'myapi')  # 输入email和key
    client = fofa.Client(email, key)                # 将email和key传入fofa.Client类进行初始化和验证,并得到一个fofa client对象
    query_str = 'header="thinkphp" || header="think_template"'
    for page in range(1, 51):                       # 从第1页查到第50页
        fcoin = client.get_userinfo()["fcoin"]      # 查询F币剩余数量
        if fcoin <= 249:
            break                                   # 当F币剩249个时,不再获取数据
        data = client.search(query_str, size=100, page=page, fields="ip,city")  # 查询第page页数据的ip和城市
        for ip, city in data["results"]:
            print("%s,%s" % (ip, city))              # 打印出每条数据的ip和城市

when i execute python3 test.py i get the next following error...

python test.py
Traceback (most recent call last):
  File "X:\scripts de python por mi\Scripts por mi\Hacking-osint\test.py", line 2, in <module>
    import fofa
  File "C:\Users\Kai\AppData\Roaming\Python\Python310\site-packages\fofa\__init__.py", line 1, in <module>
    from fofa.client import Client
  File "C:\Users\Kai\AppData\Roaming\Python\Python310\site-packages\fofa\client.py", line 42
    except urllib2.HTTPError,e:
           ^^^^^^^^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized

my python version is

Python 3.10.5

i have tried do from fofa import * etc, nothing worked, guess is error from module, hope your answer soon, thanks for read.

senvenGOD commented 2 years ago

Traceback (most recent call last): File "E:/pythonProject/小迪开发/漏洞利用/fofa-py-master/example/thinkphp_example.py", line 2, in import fofa File "C:\Users\18172\AppData\Roaming\Python\Python38\site-packages\fofa__init__.py", line 1, in from fofa.client import Client File "C:\Users\18172\AppData\Roaming\Python\Python38\site-packages\fofa\client.py", line 42 except urllib2.HTTPError,e: ^ SyntaxError: invalid syntax

环境:python3.8 win11 已经导入了fofa模块 运行报错