Ask Your Question

Libreoffice Calc Basic get WebPage page data [closed]

asked 2016-06-24 02:03:16 +0200

imrdnm gravatar image

updated 2020-09-08 17:28:19 +0200

Alex Kemp gravatar image

The code below is a Microsoft Excel VBA code. What's the LibreOffice Calc Basic equivalent of Set request = CreateObject("MSXML2.XMLHTTP") ? I am running LibreOffice 5.1 in Ubuntu 14.04.

Sub testGet
    Dim request As Object
    Dim response As String
    Dim URL As String

    Set request = CreateObject("MSXML2.XMLHTTP")
    URL = ""

    With request
        .Open "GET", URL, False
        response = .responseText
    End With
End Sub
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2020-09-08 17:28:59.834498

2 Answers

Sort by » oldest newest most voted

answered 2016-06-24 07:30:53 +0200

With EasyDev, is easy:

Sub Main
    util = createUnoService("org.universolibre.EasyDev")
    data = createUnoStruct("org.universolibre.EasyDev.Requests")

    data.Method = "get"
    data.Url = ""
    response = util.requests(data)

    util.fileSave("/home/USER/info.txt", "w", response.Text)

    MsgBox "End"
End Sub

Best regards

edit flag offensive delete link more


This requires that the user installs EasyDev first right? I was wondering if there was any way that didn't required installing additional software.

imrdnm gravatar imageimrdnm ( 2016-06-24 16:39:01 +0200 )edit

of course, not that I know

I developed EasyDev, because Basic is very poor

Best regards

mauricio gravatar imagemauricio ( 2016-06-24 18:33:46 +0200 )edit

answered 2016-06-29 06:27:35 +0200

mark_t gravatar image

updated 2016-06-29 06:42:14 +0200

You could insert a data link to get the web page data into a worksheet.

' Location for the data from the web page.
oAddress = oSheet.getCellByPosition( 0, 0 ).getCellAddress()

' The HTML sections are named HTML_all, HTML_tables, HTML_1, HTML_2, HTML_3, etc.
oDoc.AreaLinks.insertAtPosition( oAddress, url, "HTML_tables", "calc_HTML_WebQuery", "0 0" )

' Following breaks the link, but leaves the data
oDoc.AreaLinks.removeByIndex( 0 )
edit flag offensive delete link more


I don't see how this code could fetch any data. I have no problem processing html, I just have problem getting everything as text from a URL in the first place.

imrdnm gravatar imageimrdnm ( 2016-06-30 13:12:20 +0200 )edit

If you try it you will see the text from the web page is added to the worksheet, then you can search the worksheet for the data you want.

You see the format from GUI using "Sheet", "Link to External Data ...", then enter the URL, and select the part of the HTML required.

Break the link or change settings from "Edit", "Links...".

mark_t gravatar imagemark_t ( 2016-06-30 17:40:47 +0200 )edit

Question Tools



Asked: 2016-06-24 02:03:16 +0200

Seen: 2,663 times

Last updated: Jun 29 '16