Skip to content

Commit 9bc7008

Browse files
authored
Merge pull request #270 from steven-vvv/main
Remove requests dependency from ClientTransaction class
2 parents 90217d9 + c0050b1 commit 9bc7008

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

twikit/x_client_transaction/transaction.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import random
66
import base64
77
import hashlib
8-
import requests
98
from typing import Union, List
109
from functools import reduce
1110
from .cubic_curve import Cubic
@@ -56,10 +55,10 @@ async def get_indices(self, home_page_response, session, headers):
5655
key_byte_indices = list(map(int, key_byte_indices))
5756
return key_byte_indices[0], key_byte_indices[1:]
5857

59-
def validate_response(self, response: Union[bs4.BeautifulSoup, requests.models.Response]):
60-
if not isinstance(response, (bs4.BeautifulSoup, requests.models.Response)):
58+
def validate_response(self, response: bs4.BeautifulSoup):
59+
if not isinstance(response, bs4.BeautifulSoup):
6160
raise Exception("invalid response")
62-
return response if isinstance(response, bs4.BeautifulSoup) else bs4.BeautifulSoup(response.content, 'lxml')
61+
return response
6362

6463
def get_key(self, response=None):
6564
response = self.validate_response(response) or self.home_page_response
@@ -158,7 +157,3 @@ def generate_transaction_id(self, method: str, path: str, response=None, key=Non
158157
out = bytearray(
159158
[random_num, *[item ^ random_num for item in bytes_arr]])
160159
return base64_encode(out).strip("=")
161-
162-
163-
if __name__ == "__main__":
164-
pass

0 commit comments

Comments
 (0)