网络
Init 文件。
AgentQLWebReader #
使用或不使用 agentql 查询抓取 URL,并以 json 格式返回文档。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
api_key
|
str
|
AgentQL API 密钥,可在 https://dev.agentql.com 获取 |
必需 |
params
|
dict
|
要传递给 AgentQL API 的附加参数。访问 https://docs.agentql.com/rest-api/api-reference 了解详细信息。 |
无
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/agentql_web/base.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
load_data #
load_data(url: str, query: Optional[str] = None, prompt: Optional[str] = None) -> List[Document]
从输入目录加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
url
|
str
|
要抓取或爬取的 URL。 |
必需 |
query
|
Optional[str]
|
用于指定抓取数据的 AgentQL 查询。 |
无
|
prompt
|
Optional[str]
|
您想要抓取数据的自然语言描述。 |
无
|
params
|
Optional[dict]
|
要传递给 AgentQL API 的附加参数。访问 https://docs.agentql.com/rest-api/api-reference 了解详细信息。 |
必需 |
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/agentql_web/base.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
AsyncWebPageReader #
基类:BaseReader
异步网页读取器。
异步读取网页。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
html_to_text
|
bool
|
是否将 HTML 转换为文本。需要 |
False
|
limit
|
int
|
最大并发请求数。 |
10
|
dedupe
|
bool
|
如果给定列表中存在精确匹配的 URL,则进行去重 |
True
|
fail_on_error
|
bool
|
如果请求的 URL 未返回状态码 200,则例程将引发 ValueError |
False
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/async_web/base.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
aload_data async
#
aload_data(urls: List[str]) -> List[Document]
从输入 URL 加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
List[str]
|
要抓取的 URL 列表。 |
必需 |
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/async_web/base.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
load_data #
load_data(urls: List[str]) -> List[Document]
从输入 URL 加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
List[str]
|
要抓取的 URL 列表。 |
必需 |
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/async_web/base.py
120 121 122 123 124 125 126 127 128 129 130 131 |
|
BeautifulSoupWebReader #
BeautifulSoup 网页读取器。
读取网页。需要 bs4
和 urllib
包。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
website_extractor
|
Optional[Dict[str, Callable]]
|
网站主机名(例如 google.com)到指定如何从 BeautifulSoup 对象中提取文本的函数的映射。参见 DEFAULT_WEBSITE_EXTRACTOR。 |
无
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/beautiful_soup_web/base.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
class_name classmethod
#
class_name() -> str
获取类的名称标识符。
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/beautiful_soup_web/base.py
156 157 158 159 |
|
load_data #
load_data(urls: List[str], custom_hostname: Optional[str] = None, include_url_in_text: Optional[bool] = True) -> List[Document]
从 URL 加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
List[str]
|
要抓取的 URL 列表。 |
必需 |
custom_hostname
|
Optional[str]
|
在网站显示在自定义 URL 下(例如 Substack 博客)时强制使用特定的主机名 |
无
|
include_url_in_text
|
Optional[bool]
|
在文档文本中包含参考 URL |
True
|
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/beautiful_soup_web/base.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
BrowserbaseWebReader #
基类:BaseReader
BrowserbaseWebReader。
使用托管在 Browserbase 上的无头浏览器加载预渲染网页。依赖 browserbase
包。从 https://browserbase.com 获取您的 API 密钥。
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/browserbase_web/base.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
lazy_load_data #
lazy_load_data(urls: Sequence[str], text_content: bool = False, session_id: Optional[str] = None, proxy: Optional[bool] = None) -> Iterator[Document]
懒加载文档。
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/browserbase_web/base.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
要抓取或爬取的 URL 列表
turn a url to llm accessible markdown with Firecrawl.dev
.
参数:api_key: Firecrawl API 密钥。api_url: 用于本地部署传递给 FirecrawlApp 的 URL。url: 要爬取的 URL (或) mode: 加载器运行模式。默认值为 "crawl"。选项包括 "scrape"(单个 URL)、"crawl"(所有可访问的子页面)、"search"(搜索内容)和 "extract"(使用提示词从 URL 提取结构化数据)。params: 要传递给 Firecrawl API 的参数。示例包括 crawlerOptions。更多详细信息,请访问:https://docs.firecrawl.dev/sdks/python
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/firecrawl_web/base.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
load_data #
load_data(url: Optional[str] = None, query: Optional[str] = None, urls: Optional[List[str]] = None) -> List[Document]
从输入目录加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
url
|
Optional[str]
|
要抓取或爬取的 URL。 |
无
|
query
|
Optional[str]
|
要搜索的查询。 |
无
|
urls
|
Optional[List[str]]
|
extract 模式下的 URL 列表。 |
无
|
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
引发
类型 | 描述 |
---|---|
ValueError
|
如果提供了无效的参数组合。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/firecrawl_web/base.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
HyperbrowserWebReader #
基类:BaseReader
Hyperbrowser 网页读取器。
使用可选参数配置内容提取,抓取或爬取网页。需要 hyperbrowser
包。从 https://app.hyperbrowser.ai/ 获取您的 API 密钥。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
api_key
|
Optional[str]
|
Hyperbrowser API 密钥,可以设置为环境变量 |
无
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/hyperbrowser_web/base.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
lazy_load_data #
lazy_load_data(urls: List[str], operation: Literal['scrape', 'crawl'] = 'scrape', params: Optional[Dict] = {}) -> Iterable[Document]
懒加载文档。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
List[str]
|
要抓取或爬取的 URL 列表 |
必需 |
operation
|
Literal['scrape', 'crawl']
|
要执行的操作。可以是 "scrape" 或 "crawl" |
'scrape'
|
params
|
Optional[Dict]
|
抓取或爬取的可选参数。有关支持的参数的更多信息,请访问 https://docs.hyperbrowser.ai/reference/sdks/python/scrape#start-scrape-job-and-wait 或 https://docs.hyperbrowser.ai/reference/sdks/python/crawl#start-crawl-job-and-wait |
{}
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/hyperbrowser_web/base.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
alazy_load_data async
#
alazy_load_data(urls: Sequence[str], operation: Literal['scrape', 'crawl'] = 'scrape', params: Optional[Dict] = {}) -> AsyncIterable[Document]
异步懒加载文档。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
Sequence[str]
|
要抓取或爬取的 URL 列表 |
必需 |
operation
|
Literal['scrape', 'crawl']
|
要执行的操作。可以是 "scrape" 或 "crawl" |
'scrape'
|
params
|
Optional[Dict]
|
抓取或爬取的可选参数。有关支持的参数的更多信息,请访问 https://docs.hyperbrowser.ai/reference/sdks/python/scrape#start-scrape-job-and-wait 或 https://docs.hyperbrowser.ai/reference/sdks/python/crawl#start-crawl-job-and-wait |
{}
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/hyperbrowser_web/base.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
KnowledgeBaseWebReader #
基类:BaseReader
知识库读取器。
使用 Playwright 爬取并读取知识库/帮助中心的文章。在 Zendesk 和 Intercom CMS 上测试通过,可能也适用于其他系统。可以在无头模式下运行,但可能被 Cloudflare 阻止。为了安全起见,建议在非无头模式下运行。偶尔会超时,如果发生,请增加默认超时时间。需要 playwright
包。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
root_url
|
str
|
知识库的基础 URL,不带斜杠结尾,例如 'https://support.intercom.com' |
必需 |
link_selectors
|
List[str]
|
在爬取过程中查找文章链接的 css 选择器列表,例如 ['.article-list a', '.article-list a'] |
必需 |
article_path
|
str
|
此域上文章的 URL 路径,以便爬取器知道何时停止,例如 '/articles' |
必需 |
title_selector
|
Optional[str]
|
用于查找文章标题的 css 选择器,例如 '.article-title' |
无
|
subtitle_selector
|
Optional[str]
|
用于查找文章副标题/描述的 css 选择器,例如 '.article-subtitle' |
无
|
body_selector
|
Optional[str]
|
用于查找文章正文的 css 选择器,例如 '.article-body' |
无
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/knowledge_base/base.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
load_data #
load_data() -> List[Document]
从知识库加载数据。
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/knowledge_base/base.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
scrape_article #
scrape_article(browser: Any, url: str) -> Dict[str, str]
抓取单个文章 URL。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
browser
|
Any
|
Playwright Chromium 浏览器实例。 |
必需 |
url
|
str
|
要抓取的文章 URL。 |
必需 |
返回值
类型 | 描述 |
---|---|
Dict[str, str]
|
Dict[str, str]:文章属性及其值的映射。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/knowledge_base/base.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
get_article_urls #
get_article_urls(browser: Any, root_url: str, current_url: str, max_depth: int = 100, depth: int = 0) -> List[str]
递归爬取知识库以查找文章列表。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
browser
|
Any
|
Playwright Chromium 浏览器实例。 |
必需 |
root_url
|
str
|
知识库的根 URL。 |
必需 |
current_url
|
str
|
当前正在爬取的 URL。 |
必需 |
max_depth
|
int
|
爬取器的最大递归级别 |
100
|
depth
|
int
|
当前深度级别 |
0
|
返回值
类型 | 描述 |
---|---|
List[str]
|
List[str]:找到的文章 URL 列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/knowledge_base/base.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
MainContentExtractorReader #
基类:BaseReader
MainContentExtractor 网页读取器。
读取网页。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
text_format
|
str
|
文本格式。默认为 "markdown"。需要 |
'markdown'
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/main_content_extractor/base.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
load_data #
load_data(urls: List[str]) -> List[Document]
从输入目录加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
List[str]
|
要抓取的 URL 列表。 |
必需 |
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/main_content_extractor/base.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
NewsArticleReader #
基类:BaseReader
简单新闻文章读取器。
读取网页上的新闻文章并使用 newspaper
库解析。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
text_mode
|
bool
|
是否加载内容的文本版本或 HTML 版本(默认值=True)。 |
True
|
use_nlp
|
bool
|
是否使用 NLP 提取附加摘要和关键词(默认值=True)。 |
True
|
newspaper_kwargs
|
Any
|
要传递给 newspaper.Article 的附加关键字参数。参见 https://newspaper.readthedocs.io/en/stable/user_guide/quickstart.html#article |
{}
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/news/base.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
load_data #
load_data(urls: List[str]) -> List[Document]
从新闻文章 URL 列表加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
List[str]
|
要加载新闻文章的 URL 列表。 |
必需 |
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/news/base.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
OxylabsWebReader #
使用 Oxylabs Scraper 抓取任何网站。
Oxylabs API 文档:https://developers.oxylabs.io/scraper-apis/web-scraper-api/other-websites
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
username
|
str
|
Oxylabs 用户名。 |
必需 |
password
|
str
|
Oxylabs 密码。 |
必需 |
示例
.. code-block:: python from llama_index.readers.web.oxylabs_web.base import OxylabsWebReader
reader = OxylabsWebReader(
username=os.environ["OXYLABS_USERNAME"], password=os.environ["OXYLABS_PASSWORD"]
)
docs = reader.load_data(
[
"https://sandbox.oxylabs.io/products/1",
"https://sandbox.oxylabs.io/products/2"
],
{
"parse": True,
}
)
print(docs[0].text)
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/oxylabs_web/base.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
aload_data async
#
aload_data(urls: list[str], additional_params: Optional[Dict[str, Any]] = None) -> List[Document]
从 URL 异步加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
list[str]
|
要加载的 URL 列表。 |
必需 |
additional_params
|
Optional[Dict[str, Any]]
|
包含抓取器参数的字典。接受此处描述的附加参数的值:https://developers.oxylabs.io/scraper-apis/web-scraper-api/targets/generic-target#additional |
无
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/oxylabs_web/base.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
load_data #
load_data(urls: list[str], additional_params: Optional[Dict[str, Any]] = None) -> List[Document]
从 URL 加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
list[str]
|
要加载的 URL 列表。 |
必需 |
additional_params
|
Optional[Dict[str, Any]]
|
包含抓取器参数的字典。接受此处描述的附加参数的值:https://developers.oxylabs.io/scraper-apis/web-scraper-api/targets/generic-target#additional |
无
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/oxylabs_web/base.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
ReadabilityWebPageReader #
基类:BaseReader
Readability 网页加载器。
从完全渲染的网页中提取相关信息。在处理过程中,始终假定用作数据源的网页包含文本内容。
- 加载页面并等待其渲染完成。(playwright)
- 注入 Readability.js 以提取主要内容。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
proxy
|
Optional[str]
|
代理服务器。默认为 None。 |
无
|
wait_until
|
Optional[Literal['commit', 'domcontentloaded', 'load', 'networkidle']]
|
等待页面加载完成。默认为 "domcontentloaded"。 |
'domcontentloaded'
|
text_splitter
|
TextSplitter
|
文本分割器。默认为 None。 |
无
|
normalizer
|
Optional[Callable[[str], str]]
|
文本规范化器。默认为 nfkc_normalize。 |
必需 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/readability_web/base.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
async_load_data async
#
async_load_data(url: str) -> List[Document]
渲染并加载 URL 的数据内容。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
url
|
str
|
要抓取的 URL。 |
必需 |
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/readability_web/base.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
scrape_page async
#
scrape_page(browser: Browser, url: str) -> Dict[str, str]
抓取单个文章 URL。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
browser
|
Any
|
Playwright Chromium 浏览器实例。 |
必需 |
url
|
str
|
要抓取的文章 URL。 |
必需 |
返回值
名称 | 类型 | 描述 |
---|---|---|
参考 |
Dict[str, str]
|
https://github.com/mozilla/readability |
title |
Dict[str, str]
|
文章标题; |
content |
Dict[str, str]
|
处理后的文章内容的 HTML 字符串; |
textContent |
Dict[str, str]
|
文章的文本内容,已移除所有 HTML 标签; |
length |
Dict[str, str]
|
文章长度,以字符为单位; |
excerpt |
Dict[str, str]
|
文章描述,或内容的简短摘录; |
byline |
Dict[str, str]
|
作者元数据; |
dir |
Dict[str, str]
|
内容方向; |
siteName |
Dict[str, str]
|
网站名称。 |
lang |
Dict[str, str]
|
内容语言 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/readability_web/base.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
RssNewsReader #
基类:BaseReader
RSS 新闻读取器。
从 RSS Feed 读取新闻内容并使用 NewsArticleReader 进行解析。
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/rss_news/base.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
load_data #
load_data(urls: List[str] = None, opml: str = None) -> List[Document]
从 RSS Feed 或 OPML 加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
List[str]
|
要加载的 RSS URL 列表。 |
无
|
opml
|
str
|
OPML 文件 URL 或字符串或字节 OPML 内容。 |
无
|
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/rss_news/base.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
RssReader #
RSS 读取器。
从 RSS Feed 读取内容。
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/rss/base.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
load_data #
load_data(urls: List[str]) -> List[Document]
从 RSS Feed 加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
List[str]
|
要加载的 RSS URL 列表。 |
必需 |
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/rss/base.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
ScrapflyReader #
使用 Scrapfly.io
将 URL 转换为 LLM 可访问的 Markdown。
参数:api_key: Scrapfly API 密钥。scrape_config: Scrapfly ScrapeConfig 对象。ignore_scrape_failures: 是否在失败时继续。urls: 要抓取的 URL 列表。scrape_format: 抓取结果格式(markdown 或 text)。更多详细信息,请访问:https://scrapfly.io/docs/sdk/python
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/scrapfly_web/base.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
load_data #
load_data(urls: List[str], scrape_format: Literal['markdown', 'text'] = 'markdown', scrape_config: Optional[dict] = None) -> List[Document]
从 URL 加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
List[str]
|
List[str]:要抓取的 URL 列表。 |
必需 |
scrape_config
|
Optional[dict]
|
Optional[dict]:ScrapFly 抓取配置对象的字典。 |
无
|
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
引发
类型 | 描述 |
---|---|
ValueError
|
如果未提供 URL。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/scrapfly_web/base.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
SimpleWebPageReader #
简单网页读取器。
读取网页。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
html_to_text
|
bool
|
是否将 HTML 转换为文本。需要 |
False
|
metadata_fn
|
Optional[Callable[[str], Dict]]
|
接受 URL 并返回元数据字典的函数。默认为 None。 |
无
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/simple_web/base.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
load_data #
load_data(urls: List[str]) -> List[Document]
从输入目录加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
List[str]
|
要抓取的 URL 列表。 |
必需 |
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/simple_web/base.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
SitemapReader #
基类:BaseReader
Web 的异步站点地图读取器。
根据 sitemap.xml 读取网页。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
sitemap_url
|
string
|
sitemap.xml 的路径。例如 https://gpt-index.readthedocs.io/sitemap.xml |
必需 |
html_to_text
|
bool
|
是否将 HTML 转换为文本。需要 |
False
|
limit
|
int
|
最大并发请求数。 |
10
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/sitemap/base.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
TrafilaturaWebReader #
Trafilatura 网页读取器。
读取网页。需要 trafilatura
包。
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/trafilatura_web/base.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
class_name classmethod
#
class_name() -> str
获取类的名称标识符。
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/trafilatura_web/base.py
18 19 20 21 |
|
获取类的名称标识符。
load_data(urls: List[str], include_comments=True, output_format='txt', include_tables=True, include_images=False, include_formatting=False, include_links=False, show_progress=False, no_ssl=False, **kwargs) -> List[Document]
从 URL 加载数据。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
urls
|
List[str]
|
要抓取的 URL 列表。 |
必需 |
load_data #
|
bool
|
include_comments |
True
|
输出中包含评论。默认为 True。
|
str
|
output_format |
输出格式。默认为 'txt'。
|
'txt'
|
bool
|
include_tables |
True
|
输出中包含表格。默认为 True。
|
bool
|
include_images |
False
|
输出中包含图像。默认为 False。
|
bool
|
include_formatting |
False
|
输出中包含格式。默认为 False。
|
bool
|
include_links |
False
|
输出中包含链接。默认为 False。
|
bool
|
show_progress |
False
|
显示进度条。默认为 False
|
bool
|
no_ssl |
False
|
跳过 SSL 验证。默认为 False。
|
kwargs |
{}
|
返回值
类型 | 描述 |
---|---|
List[Document]
|
List[Document]:文档列表。 |
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/trafilatura_web/base.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
trafilatura.extract
函数的附加关键字参数。
基类:BaseReader
UnstructuredURLLoader #
使用 unstructured 加载 HTML 文件的加载器。
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/unstructured_web/base.py
load_data() -> List[Document]
load_data #
使用 unstructured 加载 HTML 文件的加载器。
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
加载文件。
基类:BaseReader
WholeSiteReader #
用于网站的 BFS 网页抓取器。
此类提供了使用广度优先搜索算法抓取整个网站的功能。它从给定的基本 URL 导航网页,并跟踪与指定前缀匹配的链接。
名称 | 类型 | 描述 |
---|---|---|
属性 |
str
|
prefix |
max_depth |
int
|
用于聚焦抓取的 URL 前缀。 |
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
属性
|
str
|
BFS 算法的最大深度。 |
必需 |
max_depth
|
int
|
用于抓取的 URL 前缀。 |
10
|
BFS 的最大深度。默认为 10。
|
bool
|
uri_as_id |
False
|
是否使用 URI 作为文档 ID。默认为 False。
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
源码位于 llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/whole_site/base.py
setup_driver()
setup_driver #
返回值
名称 | 类型 | 描述 |
---|---|---|
设置用于 Chrome 的 Selenium WebDriver。 |
WebDriver |
是否使用 URI 作为文档 ID。默认为 False。
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
Chrome WebDriver 的一个实例。
load_data(base_url: str) -> List[Document]
load_data #
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
使用 BFS 算法从基本 URL 加载数据。
|
str
|
base_url |
必需 |
返回值
类型 | 描述 |
---|---|
List[Document]
|
开始抓取的基本 URL。 |
是否使用 URI 作为文档 ID。默认为 False。
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|