Update app.py
Browse files
app.py
CHANGED
@@ -3,17 +3,28 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
from html.parser import HTMLParser
|
5 |
|
|
|
6 |
class MyHTMLParser(HTMLParser):
|
7 |
def __init__(self):
|
8 |
super().__init__()
|
9 |
self.data = {}
|
|
|
10 |
|
11 |
def handle_starttag(self, tag, attrs):
|
|
|
12 |
if tag == 'input':
|
13 |
d = dict(attrs)
|
14 |
if 'name' in d and 'value' in d:
|
15 |
self.data[d['name']] = d['value']
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
def extract_info_from_html(html_content):
|
18 |
parser = MyHTMLParser()
|
19 |
parser.feed(html_content)
|
@@ -21,8 +32,11 @@ def extract_info_from_html(html_content):
|
|
21 |
return {
|
22 |
"order_number": parser.data.get('ordr_idxx', 'Not found'),
|
23 |
"buyer_name": parser.data.get('buyr_name', 'Not found'),
|
|
|
24 |
# Add more extracted fields as needed
|
25 |
}
|
|
|
|
|
26 |
|
27 |
def request_batch_key(onfftid, pay_type, method, cert_type, order_no, user_nm, user_phone2, product_nm,
|
28 |
card_user_type, card_no, expire_date, auth_value, password, tot_amt):
|
|
|
3 |
import requests
|
4 |
from html.parser import HTMLParser
|
5 |
|
6 |
+
|
7 |
class MyHTMLParser(HTMLParser):
|
8 |
def __init__(self):
|
9 |
super().__init__()
|
10 |
self.data = {}
|
11 |
+
self.current_tag = None
|
12 |
|
13 |
def handle_starttag(self, tag, attrs):
|
14 |
+
self.current_tag = tag
|
15 |
if tag == 'input':
|
16 |
d = dict(attrs)
|
17 |
if 'name' in d and 'value' in d:
|
18 |
self.data[d['name']] = d['value']
|
19 |
|
20 |
+
def handle_data(self, data):
|
21 |
+
if self.current_tag == 'script':
|
22 |
+
if 'fix_key' in data:
|
23 |
+
for line in data.split('\n'):
|
24 |
+
if 'fix_key' in line:
|
25 |
+
key, value = line.split('=')
|
26 |
+
self.data['fix_key'] = value.strip().strip("';")
|
27 |
+
|
28 |
def extract_info_from_html(html_content):
|
29 |
parser = MyHTMLParser()
|
30 |
parser.feed(html_content)
|
|
|
32 |
return {
|
33 |
"order_number": parser.data.get('ordr_idxx', 'Not found'),
|
34 |
"buyer_name": parser.data.get('buyr_name', 'Not found'),
|
35 |
+
"fix_key": parser.data.get('fix_key', 'Not found'),
|
36 |
# Add more extracted fields as needed
|
37 |
}
|
38 |
+
|
39 |
+
|
40 |
|
41 |
def request_batch_key(onfftid, pay_type, method, cert_type, order_no, user_nm, user_phone2, product_nm,
|
42 |
card_user_type, card_no, expire_date, auth_value, password, tot_amt):
|