迁移类到别的文件

This commit is contained in:
vincent 2023-08-20 14:39:19 +08:00
parent e6784edd19
commit bec35a5038
4 changed files with 18 additions and 18 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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