| Python Installation |
| COM Installation |
| Python Example |
A simple example to extract url and text from links.
import htql; page="<a href=a.html>1</a><a href=b.html>2</a><a href=c.html>3</a>"; query="<a>:href,tx"; for url, text in htql.HTQL(page, query): print(url, text); |
An example using htql.Browser:
import htql;
a=htql.Browser();
b=a.goUrl("http://www.bing.com/");
c=a.goForm("<form>1", {"q":"test"});
for d in htql.HTQL(c[0], "<a (tx like '%test%')>"):
print(d);
e=a.click("<a (tx like '%test%' and not (href like '/search%'))>1");
|
If you have installed IRobotSoft Web Scraper, you can browse the web visually with:
a=htql.Browser(2); |
| JavaScript Example |
The following example shows the use of HTQL in an HTML page with JavaScript. The JavaScript code in this HTML page retrieves the first <a> tag from http://www.ncbi.nlm.nih.gov/ and show it in the HTML body.
<!--- test.html -->
<html> <base href="http://www.ncbi.nlm.nih.gov/">
<body>
<script language=JavaScript>
var a= new ActiveXObject("HtqlCom.HtqlControl");
a.setUrl("http://www.ncbi.nlm.nih.gov/");
a.setQuery("<a>");
document.write(a.getValueByIndex(1));
</script>
</body>
</html>
|
| Visual Basic Example |
The following Visual Basic example does the same thing and shows the result in a message box:
' VB example
Dim a As Object
Set a = CreateObject("HtqlCom.HtqlControl")
i = a.setUrl("http://www.ncbi.nlm.nih.gov/")
i = a.setQuery("<a>")
MsgBox (a.getValueByIndex(1))
|