迁移类到别的文件
This commit is contained in:
parent
e6784edd19
commit
bec35a5038
4
main.py
4
main.py
@ -1,6 +1,6 @@
|
|||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from requester import Requester
|
from web import Requester
|
||||||
from web_parser import HtmlParser
|
from web import HtmlParser
|
||||||
from web_img import ImgManager
|
from web_img import ImgManager
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,19 @@
|
|||||||
import requests
|
import requests
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
||||||
|
class HtmlParser:
|
||||||
|
def __init__(self, html_content: str):
|
||||||
|
self.html_content = html_content
|
||||||
|
|
||||||
|
def get_img_url_list(self):
|
||||||
|
soup = BeautifulSoup(self.html_content, "html.parser")
|
||||||
|
img_tags = soup.find("div", class_="reading-content").find_all("img")
|
||||||
|
img_urls = []
|
||||||
|
for img_tag in img_tags:
|
||||||
|
img_url = img_tag.attrs["data-src"]
|
||||||
|
img_urls.append(img_url)
|
||||||
|
return img_urls
|
||||||
|
|
||||||
|
|
||||||
class Requester:
|
class Requester:
|
||||||
@ -1,6 +1,6 @@
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
import io
|
import io
|
||||||
from requester import Requester
|
from web import Requester
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
from bs4 import BeautifulSoup
|
|
||||||
|
|
||||||
|
|
||||||
class HtmlParser:
|
|
||||||
def __init__(self, html_content: str):
|
|
||||||
self.html_content = html_content
|
|
||||||
|
|
||||||
def get_img_url_list(self):
|
|
||||||
soup = BeautifulSoup(self.html_content, "html.parser")
|
|
||||||
img_tags = soup.find("div", class_="reading-content").find_all("img")
|
|
||||||
img_urls = []
|
|
||||||
for img_tag in img_tags:
|
|
||||||
img_url = img_tag.attrs["data-src"]
|
|
||||||
img_urls.append(img_url)
|
|
||||||
return img_urls
|
|
||||||
Loading…
Reference in New Issue
Block a user