方式有点隐蔽,在实例化 Goose 的时候,作为集成到第一个参数里面传入

示例如下:

from goose3 import Goose
from goose3.text import StopWordsChinese
from loguru import logger
import json

proxy = 'http://xxxxx:xxxxx@xxx.xxx.xxx.xx:xxxx'

http_proxies = {
    'http': proxy,
    'https': proxy
}


url = 'https://www.88mv.org/guochanju/202310/229277.html'
g = Goose(
    config={
        'stopwords_class': StopWordsChinese,
        'enable_image_fetching': True,
        'http_proxies': http_proxies
    }
)


article = g.extract(url=url)
logger.debug(json.dumps(article.infos, indent=4, ensure_ascii=False))

universe_king
3.4k 声望680 粉丝