How to get data in html from this Url??
lazarus / 38-Networking and Web Programming
----------------------------------------------------------------------
lestroso · 2021-05-26 21:27
Hi, i need to retrieve data from this url:"
https://www.betexplorer.com/next/soccer/"
Because i need to make some operations from that url..
I need to use a command like "wordoffset" to cut the html text
imported into a variable until find some team soccer...like "Germany:
Bundesliga" and then get all the teams for that type of soccer
Team...and put it into a field...
Can you help me with some fresh code example please??Can you help me??
Thanks A lot!! Lestroso
----------------------------------------------------------------------
fpcoder · 2021-05-26 22:02
No much code, but a general idea how I usually do it:
Read all of the html content into a TStringList.
Create a function that finds the first entry, then
another similar function that find a next entry
Then run the findnext routine in a loop until it returns false.
Just look for suitable keywords inside the html and strip out the data
you need.
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i if
findfirstrecord then GrabResults()else Exit; Code: Pascal
[Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i while
findnextrecord dobegin GrabResults();end;
----------------------------------------------------------------------
Jurassic Pork · 2021-05-27 03:29
hello,
Quote from: lestroso on May 26, 2021, 11:27:22 pmHi, i need to
retrieve data from this url:"
https://www.betexplorer.com/next/soccer/"
Because i need to make some operations from that url..
I need to use a command like "wordoffset" to cut the html text
imported into a variable until find some team soccer...like "Germany:
Bundesliga" and then get all the teams for that type of soccer
Team...and put it into a field...
Can you help me with some fresh code example please??Can you help me??
Thanks A lot!! Lestroso
To do that you can try my library WebDriver4L using a webbrowser like
chrome or firefox.
With this code :
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i procedure
TForm1.Button1Click(Sender: TObject);var Robot : TWebDriver; teams
: TWebElements; i : integer;begin {$IFDEF WINDOWS} Robot :=
TChromeDriver.Create(nil); // Robot := TFireFoxDriver.Create(nil);
Robot.StartDriver(ExtractFileDir(Paramstr(0)) + '\chromedriver.exe');
// Robot.StartDriver(ExtractFileDir(Paramstr(0)) +
'\geckodriver.exe'); {$ELSE} // Robot :=
TChromeDriver.Create(nil); Robot := TFireFoxDriver.Create(nil); //
Robot.StartDriver(ExtractFileDir(Paramstr(0)) + '/chromedriver');
Robot.StartDriver(ExtractFileDir(Paramstr(0)) + '/geckodriver');
{$ENDIF} // Sleep(2000); Robot.NewSession;
Robot.Implicitly_Wait(2000); Robot.Set_Window_Size(1280, 1024); Robo
t.GetURL('https://www.betexplorer.com/soccer/germany/bundesliga/');
teams :=
Robot.FindElementsByXPath('//span[@class="team_name_span"]'); For
i:=0 to teams.Count - 1 do begin
Memo1.Append(teams.Items[i].Text); end; Sleep(20000);
Robot.Quit;end;
i get what you can see in attachment.
Friendly, J.P
----------------------------------------------------------------------
wp · 2021-05-27 12:04
You can also solve this without using third-party software: Use unit
fasthtmlparser which comes with FPC; it iterates through the html text
character by character and fires an event OnFoundTag whenever a tag is
seen and returns the text between the '<' and the '>'. And it fires an
event OnFoundText whenever it sees a text node and returns the text
between then '>' of the previous tag and the '<' of the following tag.
Studying the nodes of the input text and introducing some state
variables it is relatively straightforward to extract the desired
information. Check out the attached demo. Note that you must make sure
that the SSL libraries can be found - in Windows you normally must
copy the libeay32.dll and ssleay32.dll into the exe folder. Note also
that I did not manage to download from the given site using the
fphttpclient which comes with FPC, and that I had to use synapse
instead - so make sure that the synapse package is available.
----------------------------------------------------------------------
BeniBela · 2021-05-27 13:03
I made my Internet Tools for such purposes:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i uses simple
internet,;writeln(process('https://www.betexplorer.com/soccer/germany/
bundesliga', 'distinct-values(css(".in-match
span"))').toJoinedString(lineEnding));