在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):lachenmayer/graphql-scraper开源软件地址(OpenSource Url):https://github.com/lachenmayer/graphql-scraper开源编程语言(OpenSource Language):TypeScript 92.6%开源软件介绍(OpenSource Introduction):graphql-scraperGraphQL lets us query all sorts of graph-shaped data - so why not use it to query the world's most useful graph, the web?
Check out a live demo here. You can easily spin up your own by using The command-line tool
or
Reads a GraphQL query from the path If Command-line options
VariablesAny other named options you pass to the CLI will be used as a query variable. For example, if you want to reuse the same query on several pages, you could write the following query file ( query ExampleQueryWithVariable($page: String) {
page(url: $page) {
items: queryAll(selector: "tr.athing") {
rank: text(selector: "td span.rank")
title: text(selector: "td.title a")
sitebit: text(selector: "span.comhead a")
url: attr(selector: "td.title a", name: "href")
attrs: next {
score: text(selector: "span.score")
user: text(selector: "a:first-of-type")
comments: text(selector: "a:nth-of-type(3)")
}
}
}
} ...and execute the query like this: graphql-scraper query.graphql --page="https://news.ycombinator.com/" The schemaYou can check out an auto-generated schema description here, but I recommend trying out the graphql-scraper-server example and exploring the types interactively. You can also play around with the schema in the live demo. Re-using the schema in your own projectsThe npm package exports the GraphQL schema which is used by the command-line tool. This an instance of graphql-js Use
Basic example with |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论