Jump to content

Recommended Posts

Posted

Hello,

I'll try to explain what I am looking for.

For example let's take this website: https://www.bristol.ac.uk/arts/exercises/grammar/grammar_tutorial/page_05.htm

What I want to make is: the script does something like CTRL + F and finds a line with word example. If some of the lines found with word example, I want to copy all possible full lines with the word example (even if it's not a complete sentence) to a variable.

Screenshot below:

So now, as you see, for example, the script found here 2 lines with word example, and now I want to copy both full lines with this word to a variable in AutoIt.

image.thumb.png.279de6a92e5f5f21cf3503893afc6400.png

 

Is it possible to make it work? Maybe you have something similar created already or can give me an idea of how I can create a code that would do that for me? Or perhaps it's not possible at all? :)

 

Sorry for my bad English, hope you understood what I meant :)

Posted

I'm sure that there are lots of different ways to tackle this. Here's one quick example that processes the raw HTML --

#include <array.au3>
#include <Inet.au3>

$sURL = 'https://www.bristol.ac.uk/arts/exercises/grammar/grammar_tutorial/page_05.htm'
$sHTML = _INetGetSource($sURL)
$sSearchWord = "example"
$sPattern = "(?m)^.*\b" & $sSearchWord & "\b.*$"

$aMatches = StringRegExp($sHTML, $sPattern, $STR_REGEXPARRAYGLOBALMATCH)
ConsoleWrite(@error & @crlf)

_ArrayDisplay($aMatches)

 

Posted (edited)
15 minutes ago, Danp2 said:

I'm sure that there are lots of different ways to tackle this. Here's one quick example that processes the raw HTML --

#include <array.au3>
#include <Inet.au3>

$sURL = 'https://www.bristol.ac.uk/arts/exercises/grammar/grammar_tutorial/page_05.htm'
$sHTML = _INetGetSource($sURL)
$sSearchWord = "example"
$sPattern = "(?m)^.*\b" & $sSearchWord & "\b.*$"

$aMatches = StringRegExp($sHTML, $sPattern, $STR_REGEXPARRAYGLOBALMATCH)
ConsoleWrite(@error & @crlf)

_ArrayDisplay($aMatches)

 

Wow, looks that simple and works perfectly at least with this website of HTML code. Thank you :)

Also, another question, what if my website will have other pages from 1 to 20 for example, so I use CTRL+F to find word example. When the search ends, it automatically jumps to another just by searching with ctrl+f the same word and shows on another page instantly (when I click enter all the time in CTRL+F), is it possible to make something similar with a script? What can I read to understand how I can make it?

 

Can't give you the web for example as it is restricted for public view. :{

Edited by diff
Posted
17 hours ago, FrancescoDiMuro said:

@diff

You need to use a For loop to iterate through all the pages, from 1 to 20, and use the code above in the loop :)

I understand, but does it will help if the pages stay on the same page and in the link of the website doesn't change anything?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...