diff Posted April 24, 2020 Posted April 24, 2020 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. 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
Danp2 Posted April 24, 2020 Posted April 24, 2020 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) Latest Webdriver UDF Release Webdriver Wiki FAQs
diff Posted April 24, 2020 Author Posted April 24, 2020 (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 April 24, 2020 by diff
FrancescoDiMuro Posted April 25, 2020 Posted April 25, 2020 @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 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
diff Posted April 25, 2020 Author Posted April 25, 2020 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?
FrancescoDiMuro Posted April 26, 2020 Posted April 26, 2020 6 hours ago, diff said: but does it will help if the pages stay on the same page What do you mean? In order to looo through pages, the link must change (page_1, page_2, and so on). Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now