copy google define definitions and write them in a text file
-
- Posts: 9
- Joined: 22 Oct 2022, 09:31
copy google define definitions and write them in a text file
i have a list of words and all of the words are verbs. i want to automatically copy definitions of the verbs with google define and save them as a new text file like in the screen shot
notice: sometimes there`s no number about the difinition version like the number 1 in the screenshot
it has to detect the word verb and a number infront of the definition
notice: sometimes there`s no number about the difinition version like the number 1 in the screenshot
it has to detect the word verb and a number infront of the definition
-
- Posts: 9
- Joined: 22 Oct 2022, 09:31
Re: copy google define definitions and write them in a text file
here`s the verbs list
Re: copy google define definitions and write them in a text file
Welcome to this AutoHotkey forum!
A few ideas are below. Adjust as needed.
A few ideas are below. Adjust as needed.
Code: Select all
dir = %A_ScriptDir%
words = %dir%\words.txt
out = %dir%\definitions.txt
If !FileExist(words) {
MsgBox, 48, Error, File not found.`n`n%words%
Return
}
ToolTip, Working....
SoundBeep, 1500
FileRecycle, %out%
Loop, Read, %words%, %out%
FileAppend, % Trim(A_LoopReadLine) " " def(Trim(A_LoopReadLine, " =")) "`n"
ToolTip
Run, %out%
def(word) {
Static file := A_ScriptDir "\out.html"
UrlDownloadToFile, https://www.google.com/search?q=define+%word%, %file%
If !ErrorLevel {
FileRead, html, %file%
FileRecycle, %file%
RegExMatch(html, "(<div class=[^>]+?>){2}\K[a-z ,()]{2,}", def)
Return def
} Else MsgBox, 48, Error, An error occurred during the download.`n`n%url%
}
Re: copy google define definitions and write them in a text file
If it says "noun" before "verb" it does not work, it doesn't copy the definition
Re: copy google define definitions and write them in a text file
It's just an example. You may need to adjust.
-
- Posts: 9
- Joined: 22 Oct 2022, 09:31
Re: copy google define definitions and write them in a text file
My script worked in my brief test, but the regex would likely need adjustment. There may be a Google API to improve efficiency and reliability. I was offering an idea but do not have full knowledge of the formats that Google uses for these pages. You might be able to deduce them by examining a larger sample of output.
Re: copy google define definitions and write them in a text file
@mikeyww your script works fine ( used less words )
Code: Select all
words := a_scriptdir . "\words.txt"
out := a_scriptdir . "\definitions.txt"
;- example with few words :
ifnotexist,%words%
{
e:="
(Ltrim Join`r`n
afford =
affix =
age =
aggregate =
allow =
)"
fileappend,%e%,%words%,utf-8
}
If !FileExist(words) {
MsgBox, 48, Error, File not found.`n`n%words%
Return
}
;-------------------
ToolTip, Working....
SoundBeep, 1500
FileRecycle, %out%
Loop, Read, %words%, %out%
FileAppend, % Trim(A_LoopReadLine) " " def(Trim(A_LoopReadLine`, " =")) "`r`n"
ToolTip
Run, %out%
exitapp
;-----------
def(word) {
Static file := A_ScriptDir "\out.html"
UrlDownloadToFile, https://www.google.com/search?q=define+%word%, %file%
If !ErrorLevel {
FileRead, html, %file%
FileRecycle, %file%
RegExMatch(html, "(<div class=[^>]+?>){2}\K[a-z ,()]{2,}", def)
Return def
} Else MsgBox, 48, Error, An error occurred during the download.`n`n%url%
}
esc::exitapp
;=============================
Re: copy google define definitions and write them in a text file
Thanks for the testing & feedback, garry. For mutantGOD, the Web has various regex tutorials in case needed to do some tuning. I can't say it's easy to learn, but on the other hand, the price is free!
-
- Posts: 9
- Joined: 22 Oct 2022, 09:31
Re: copy google define definitions and write them in a text file
can you test it with this text filegarry wrote: ↑23 Oct 2022, 02:02@mikeyww your script works fine ( used less words )Code: Select all
words := a_scriptdir . "\words.txt" out := a_scriptdir . "\definitions.txt" ;- example with few words : ifnotexist,%words% { e:=" (Ltrim Join`r`n afford = affix = age = aggregate = allow = )" fileappend,%e%,%words%,utf-8 } If !FileExist(words) { MsgBox, 48, Error, File not found.`n`n%words% Return } ;------------------- ToolTip, Working.... SoundBeep, 1500 FileRecycle, %out% Loop, Read, %words%, %out% FileAppend, % Trim(A_LoopReadLine) " " def(Trim(A_LoopReadLine`, " =")) "`r`n" ToolTip Run, %out% exitapp ;----------- def(word) { Static file := A_ScriptDir "\out.html" UrlDownloadToFile, https://www.google.com/search?q=define+%word%, %file% If !ErrorLevel { FileRead, html, %file% FileRecycle, %file% RegExMatch(html, "(<div class=[^>]+?>){2}\K[a-z ,()]{2,}", def) Return def } Else MsgBox, 48, Error, An error occurred during the download.`n`n%url% } esc::exitapp ;=============================
Re: copy google define definitions and write them in a text file
mutantGOD, what did your test show? You can post your output file. Ensure that file paths match what is in the script.
Code: Select all
bare (of a person or part of the body) not clothed or covered
bargain an agreement between two or more parties as to what each party will do for the other
bark the sharp explosive cry of certain animals, especially a dog, fox, or seal
bat (of a team or a player in sports such as baseball) take in turns the role of hitting rather than fielding
batch a quantity or consignment of goods produced at one time
bath an act or process of immersing and washing one
batter strike repeatedly with hard blows
...
Re: copy google define definitions and write them in a text file
yes , it worked ...
Code: Select all
bare
bargain
bark
bat
batch
bath
batter
be
beam
bear
beat
become
bed
beg
begin
behead
believe
belittle
belong
belt
benefit
best
bet
better
beware
bicycle
bid
big
bike
bill
bin
bind
bird
bisect
bite
black
bleed
blend
blind
block
blood
blunder
board
bob
bomb
bone
book
boomerang
boot
bore
born
borrow
boss
bother
bottom
bound
box
brace
bracket
braid
brain
;=====================================================
bare (of a person or part of the body) not clothed or covered
bargain an agreement between two or more people or groups as to what each will do for the other
bark the sharp explosive cry of a dog, fox, or seal
bat an implement with a handle and a solid surface, typically of wood, used for hitting the ball in games such as cricket, baseball, and table tennis
batch a quantity or consignment of goods produced at one time
bath a large container for water, used for immersing and washing the body
batter strike repeatedly with hard blows
be exist
beam a long, sturdy piece of squared timber or metal used to support the roof or floor of a building
bear carry the weight of
beat strike (a person or an animal) repeatedly and violently so as to hurt or injure them, typically with an implement such as a club or whip
become begin to be
bed a piece of furniture for sleep or rest, typically a framework with a mattress
beg ask someone earnestly or humbly for something
begin perform or undergo the first part of (an action or activity)
behead cut off the head of (someone), especially as a form of execution
believe accept that (something) is true, especially without proof
belittle dismiss (someone or something) as unimportant
belong be the property of
belt a strip of leather or other material worn, typically round the waist, to support or hold in clothes or to carry weapons
benefit an advantage or profit gained from something
best of the most excellent or desirable type or quality
bet risk a sum of money or valued item against someone else
better more desirable, satisfactory, or effective
beware be cautious and alert to risks or dangers
bicycle a vehicle consisting of two wheels held in a frame one behind the other, propelled by pedals and steered with handlebars attached to the front wheel
bid offer (a certain price) for something, especially at an auction
big of considerable size or extent
bike a bicycle or motorcycle
bill a printed or written statement of the money owed for goods or services
bin throw (something) away by putting it in a bin
bind tie or fasten (something) tightly together
bird a warm
bisect divide into two parts
bite (of a person or animal) use the teeth to cut into or through something
black of the very darkest colour owing to the absence of or complete absorption of light
bleed lose blood from the body as a result of injury or illness
blend mix (a substance) with another substance so that they combine together
blind unable to see because of injury, disease, or a congenital condition
block a large solid piece of hard material, especially rock, stone, or wood, typically with flat surfaces on each side
blood the red liquid that circulates in the arteries and veins of humans and other vertebrate animals, carrying oxygen to and carbon dioxide from the tissues of the body
blunder a stupid or careless mistake
board a long, thin, flat piece of wood or other hard material, used for floors or other building purposes
bob make a quick, short movement up and down
bomb a container filled with explosive or incendiary material, designed to explode on impact or when detonated by a timing, proximity, or remote
bone any of the pieces of hard whitish tissue making up the skeleton in humans and other vertebrates
book a written or printed work consisting of pages glued or sewn together along one side and bound in covers
boomerang (of a plan or action) recoil on the originator
boot a sturdy item of footwear covering the foot and ankle, and sometimes also the lower leg
bore make (a hole) in something with a tool or by digging
born existing as a result of birth
borrow take and use (something belonging to someone else) with the intention of returning it
boss a person who is in charge of a worker, group, or organization
bother take the trouble to do something
bottom the lowest point or part of something
bound walk or run with leaping strides
box a container with a flat base and sides, typically square or rectangular and having a lid
brace a device fitted to something, in particular a weak or injured part of the body, to give support
bracket each of a pair of marks ( )
braid threads of silk, cotton, or other material woven into a decorative band for edging or trimming garments
brain an organ of soft nervous tissue contained in the skull of vertebrates, functioning as the coordinating centre of sensation and intellectual and nervous activity
;========================================================
-
- Posts: 9
- Joined: 22 Oct 2022, 09:31
Re: copy google define definitions and write them in a text file
it doesn`t work on my pc, i switched os twicegarry wrote: ↑23 Oct 2022, 08:32yes , it worked ...Code: Select all
bare bargain bark bat batch bath batter be beam bear beat become bed beg begin behead believe belittle belong belt benefit best bet better beware bicycle bid big bike bill bin bind bird bisect bite black bleed blend blind block blood blunder board bob bomb bone book boomerang boot bore born borrow boss bother bottom bound box brace bracket braid brain ;===================================================== bare (of a person or part of the body) not clothed or covered bargain an agreement between two or more people or groups as to what each will do for the other bark the sharp explosive cry of a dog, fox, or seal bat an implement with a handle and a solid surface, typically of wood, used for hitting the ball in games such as cricket, baseball, and table tennis batch a quantity or consignment of goods produced at one time bath a large container for water, used for immersing and washing the body batter strike repeatedly with hard blows be exist beam a long, sturdy piece of squared timber or metal used to support the roof or floor of a building bear carry the weight of beat strike (a person or an animal) repeatedly and violently so as to hurt or injure them, typically with an implement such as a club or whip become begin to be bed a piece of furniture for sleep or rest, typically a framework with a mattress beg ask someone earnestly or humbly for something begin perform or undergo the first part of (an action or activity) behead cut off the head of (someone), especially as a form of execution believe accept that (something) is true, especially without proof belittle dismiss (someone or something) as unimportant belong be the property of belt a strip of leather or other material worn, typically round the waist, to support or hold in clothes or to carry weapons benefit an advantage or profit gained from something best of the most excellent or desirable type or quality bet risk a sum of money or valued item against someone else better more desirable, satisfactory, or effective beware be cautious and alert to risks or dangers bicycle a vehicle consisting of two wheels held in a frame one behind the other, propelled by pedals and steered with handlebars attached to the front wheel bid offer (a certain price) for something, especially at an auction big of considerable size or extent bike a bicycle or motorcycle bill a printed or written statement of the money owed for goods or services bin throw (something) away by putting it in a bin bind tie or fasten (something) tightly together bird a warm bisect divide into two parts bite (of a person or animal) use the teeth to cut into or through something black of the very darkest colour owing to the absence of or complete absorption of light bleed lose blood from the body as a result of injury or illness blend mix (a substance) with another substance so that they combine together blind unable to see because of injury, disease, or a congenital condition block a large solid piece of hard material, especially rock, stone, or wood, typically with flat surfaces on each side blood the red liquid that circulates in the arteries and veins of humans and other vertebrate animals, carrying oxygen to and carbon dioxide from the tissues of the body blunder a stupid or careless mistake board a long, thin, flat piece of wood or other hard material, used for floors or other building purposes bob make a quick, short movement up and down bomb a container filled with explosive or incendiary material, designed to explode on impact or when detonated by a timing, proximity, or remote bone any of the pieces of hard whitish tissue making up the skeleton in humans and other vertebrates book a written or printed work consisting of pages glued or sewn together along one side and bound in covers boomerang (of a plan or action) recoil on the originator boot a sturdy item of footwear covering the foot and ankle, and sometimes also the lower leg bore make (a hole) in something with a tool or by digging born existing as a result of birth borrow take and use (something belonging to someone else) with the intention of returning it boss a person who is in charge of a worker, group, or organization bother take the trouble to do something bottom the lowest point or part of something bound walk or run with leaping strides box a container with a flat base and sides, typically square or rectangular and having a lid brace a device fitted to something, in particular a weak or injured part of the body, to give support bracket each of a pair of marks ( ) braid threads of silk, cotton, or other material woven into a decorative band for edging or trimming garments brain an organ of soft nervous tissue contained in the skull of vertebrates, functioning as the coordinating centre of sensation and intellectual and nervous activity ;========================================================
can you create like 4 files for me if it works for you
Re: copy google define definitions and write them in a text file
Now I had no success , get error from google if use a loop with many words
maybe try with few words ....
to see this error , don't delete the html-file
FileRead, html, %file%
;FileDelete, %file%
maybe try with few words ....
to see this error , don't delete the html-file
FileRead, html, %file%
;FileDelete, %file%
Code: Select all
Our systems have detected unusual traffic from your computer network. This page checks to see if it's really you sending the requests, and not a robot.
Why did this happen?
This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the Terms of Service.
The block will expire shortly after those requests stop.
In the meantime, solving the above CAPTCHA will let you continue to use our services.
This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests.
If you share your network connection, ask your administrator for help — a different computer using the same IP address may be responsible.
Learn more
Sometimes you may be asked to solve the CAPTCHA if you are using advanced terms that robots are known to use, or sending requests very quickly.
IP address: 1210:52cd: xxxx
Time: 2022-10-23T18:14:07Z
URL: https://www.google.com/search?q=define+allow
Re: copy google define definitions and write them in a text file
I've had this happen as well, at times, with Google. The APIs, when available, are likely to be more reliable and consistent.