Send and receive data to and from a website using the TWebbrowser component in Delphi

Jan*_*ich 3 html delphi twebbrowser web

I'm creating a VCL Application with Delpi 10.3 and want to support some web functionality by having the user enter the ISBN of a book into a TEdit component and from there passing/sending this value to a search field on this website: https://isbnsearch.org after which the website looks up the ISBN and displays the Author of the book. I want to somehow access the information (i.e Author) presented by the search result and again use it in my application.

This is my GUI, for a better idea of what I want to accomplish:

在此处输入图片说明

What code can I use for this? Any other feasible suggestions or approaches are acceptable.

Jer*_*dge 5

在该网站上执行搜索时,它只会加载带有特定URL查询字符串的页面...

https://isbnsearch.org/search?s=suess
Run Code Online (Sandbox Code Playgroud)

上面的示例是当我搜索“ suess”时,因此您可以轻松地连接搜索URL。

您可以使用任何HTTP组件(例如TIdHTTP)来加载此搜索页面,然后使用HTML解析器来刮取该页面并阅读所需内容。比尝试通读TWebBrowser。要容易得多。

在此处输入图片说明

最后,您实际上不会显示HTML(如果您愿意的话,您可以显示HTML),但是其想法是读取数据并以您自己的格式显示。

在该特定页面上,首先找到ulID 为的元素searchresults。然后,每个li元素包含单独的结果。不幸的是,该网站使用分页,每页仅显示10条结果。为此,请使用&p=2第二个页面,&p=3第三个页面的另一个参数再次调用该页面。


另一方面,这是获取此类信息的最差方法。您应该做的是使用适当的API,该API为您提供机器友好的数据。您所引用的服务似乎没有选项,但是下面是其中一个示例:

https://openlibrary.org/dev/docs/api/books -这似乎也为您提供MUCH比您正在使用的一个更多的信息。