Get translation DATA from iframe.

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information:CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
c0d300b
Posts: 3
Joined: Thu Mar 21, 2019 8:51 pm

Get translation DATA from iframe.

Post by c0d300b » Thu Mar 21, 2019 9:05 pm

I am trying to copy the data from the ifrane with the translated content. Copied to clip board or stored in a variable, both would be ok. BUt i think copied to clip board would be best. Later i need to paste the data into a form but thats an other story. ;)

I tried a lot of things, this is the latest.

Code: Select all

VERSION BUILD=12.5.2018.1105
TAB T=1
TAB CLOSEALLOTHERS
'SET !PLAYBACKDELAY 0.00
URL GOTO=https://translate.google.de/translate?sl=auto&tl=de&u=https://en.wikipedia.org/wiki/Main_Page
FRAME NAME=c
TAG POS=1 TYPE=HTML ATTR=* EXTRACT=HTM 
PROMPT {{!EXTRACT}}
Thanks so much for your help, I downloaded the demo a few days ago so i am a real beginner.
chivracq
Posts: 8523
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Get translation DATA from iframe.

Post by chivracq » Thu Mar 21, 2019 9:36 pm

c0d300b wrote:
Thu Mar 21, 2019 9:05 pm
I am trying to copy the data from the ifrane with the translated content. Copied to clip board or stored in a variable, both would be ok. BUt i think copied to clip board would be best. Later i need to paste the data into a form but thats an other story. ;)

I tried a lot of things, this is the latest.

Code: Select all

VERSION BUILD=12.5.2018.1105
TAB T=1
TAB CLOSEALLOTHERS
'SET !PLAYBACKDELAY 0.00
URL GOTO=https://translate.google.de/translate?sl=auto&tl=de&u=https://en.wikipedia.org/wiki/Main_Page
FRAME NAME=c
TAG POS=1 TYPE=HTML ATTR=* EXTRACT=HTM 
PROMPT {{!EXTRACT}}
Thanks so much for your help, I downloaded the demo a few days ago so i am a real beginner.
FCI:
iMB v12.5 'Trial', OS=Win...?

Hum, OK, but what is the "Pb"...?, what do you want exactly...?
=> What Content exactly do you want to extract from that Frame...?
'EXTRACT=HTM' will extract the HTML Source of the Page/Frame, while 'EXTRACT=TXT' will "only" extract the Text Content, but "Formatting" gets a bit "lost" in the Process...

Maybe "easier" for you would be to "work" directly on the Frame with 'Open Frame in a New Tab' which will give this "Result" and you can use that same URL directly with the 'URL GOTO'... :idea:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
c0d300b
Posts: 3
Joined: Thu Mar 21, 2019 8:51 pm

Re: Get translation DATA from iframe.

Post by c0d300b » Thu Mar 21, 2019 10:01 pm

First things first. Thank you for taking the time to think about this this.

It's on win10 and I am using imacros for IE.

Maybe "easier" for you would be to "work" directly on the Frame with 'Open Frame in a New Tab' which will give this "Result" and you can use that same URL directly with the 'URL GOTO'... :idea:
I thought the same thing, I actually tried to isolate and download the frame with php, doesnt work.
If copy the url, or in your case share it. It loads a mainpage with a frame again.(1)
Does it work for you to load the frame in a new tab? How do you know what frame to load?

If it could get text only it would be enough. It doesn't need to be html.
Attachments
ggl.jpg
(1)
chivracq
Posts: 8523
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Get translation DATA from iframe.

Post by chivracq » Thu Mar 21, 2019 11:18 pm

c0d300b wrote:
Thu Mar 21, 2019 10:01 pm
First things first. Thank you for taking the time to think about this this.

It's on win10 and I am using imacros for IE.

Maybe "easier" for you would be to "work" directly on the Frame with 'Open Frame in a New Tab' which will give this "Result" and you can use that same URL directly with the 'URL GOTO'... :idea:
I thought the same thing, I actually tried to isolate and download the frame with php, doesnt work.
If copy the url, or in your case share it. It loads a mainpage with a frame again.(1)
Does it work for you to load the frame in a new tab? How do you know what frame to load?

If it could get text only it would be enough. It doesn't need to be html.
Ah, OK for your FCI...

Hum, the "Idea" I had is stg like this:

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
URL GOTO=https://translate.google.de/translate?sl=auto&tl=de&u=https://en.wikipedia.org/wiki/Main_Page
TAG POS=1 TYPE=IFRAME ATTR=* EXTRACT=HREF

TAB OPEN
TAB T=2
URL GOTO={{!EXTRACT}}
But hum, Google seems to recreate the same HTML Structure on the next Page, and with the Frame again... :evil:

The first Frame URL I had posted in the "Result" Link got obtained "manually" from the Browser (Pale Moon v26.3.3) with 'Open Frame in a New Tab'.

But Google (and Gmail + FB also) is/are always a huge pain in the ass when trying to play and extract/copy&paste URL's as they always want you to click on every URL before redirecting you to the "real" URL that you want...

Then OK, fair enough, then I tried playing directly with the (translated) Content from that Wikipedia Page inside the Frame, and it seems to work if I understood correctly want you want to extract:

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
URL GOTO=https://translate.google.de/translate?sl=auto&tl=de&u=https://en.wikipedia.org/wiki/Main_Page
FRAME NAME="c"
TAG POS=1 TYPE=SPAN ATTR=TXT:Today's<SP>featured<SP>article<SP>Der<SP>heute<SP>vorgestell*
'TAG POS=1 TYPE=P ATTR=TXT:Fôrça<SP>Bruta<SP>(<SP>Brute<SP>Force<SP>)<SP>is<SP>the<SP>s*
TAG POS=R1 TYPE=P ATTR=TXT:* EXTRACT=TXT
(Tested on iMacros for FF v8.8.2, PM v26.3.3, Win10_x64.)

=> See the Result in the '!EXTRACT_TEST_POPUP' Popup...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
c0d300b
Posts: 3
Joined: Thu Mar 21, 2019 8:51 pm

Re: Get translation DATA from iframe.

Post by c0d300b » Fri Mar 22, 2019 5:50 am


But Google (and Gmail + FB also) is/are always a huge pain in the ass when trying to play and extract/copy&paste URL's as they always want you to click on every URL before redirecting you to the "real" URL that you want...
True.


okay your script works. This could be a step in the right direction.

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
URL GOTO=https://translate.google.de/translate?sl=auto&tl=de&u=https://en.wikipedia.org/wiki/Main_Page
FRAME NAME="c"
TAG POS=1 TYPE=SPAN ATTR=TXT:Today's<SP>featured<SP>article<SP>Der<SP>heute<SP>vorgestell*
'TAG POS=1 TYPE=P ATTR=TXT:Fôrça<SP>Bruta<SP>(<SP>Brute<SP>Force<SP>)<SP>is<SP>the<SP>s*
TAG POS=R1 TYPE=P ATTR=TXT:* EXTRACT=TXT

It gets the full first paragraph about dinosaurs. So i tried to set an other identifier to wrap the content in.
But I dont understand imacros well enough.

Code: Select all

 'TAG POS=1 TYPE=P ATTR=TXT:Fôrça<SP>Bruta<SP>(<SP>Brute<SP>Force<SP>)<SP>is<SP>the<SP>s*
This is commented out with ' . why? As I understand ' makes imacros ignore the following commands withine the same line.

I have full control over the content before its translated so I can set it up in any way that I want. I can wrap in into <tags> </tags> or just put a sentence or start word front. So how can I use this

Code: Select all

TAG POS=R1 TYPE=P ATTR=TXT:* EXTRACT=TXT
to get the transalted content. Can I use this?

Code: Select all

TAG POS=R1 TYPE=tag ATTR=TXT:* EXTRACT=TXT
chivracq
Posts: 8523
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Get translation DATA from iframe.

Post by chivracq » Fri Mar 22, 2019 6:20 am

Yeah well, the commented out Line:

Code: Select all

'TAG POS=1 TYPE=P ATTR=TXT:Fôrça<SP>Bruta<SP>(<SP>Brute<SP>Force<SP>)<SP>is<SP>the<SP>s*
... was what the Record Mode recorded, and which was using the 'TXT' Attribute that would be different of course if you tried to apply the Script to some other Page with some different Content, so I made it more "generic" with:

Code: Select all

TAG POS=1 TYPE=P ATTR=TXT:* EXTRACT=TXT
(... With "POS=1".)
And I always keep in "my" Scripts the original Recording in case I ever need to edit the Script (sometimes several years later) and understand "again" what I had done when I had created the Script... (Good Practice I would say, ah-ah...!)

I didn't check but in case there might be several 'P' HTML Elements on the/this Page or on some other Pages, I supposed the "Der heute vorgestellte Artikel" Title that iMacros recorded as "Today's<SP>featured<SP>article<SP>Der<SP>heute<SP>vorgestell*" and that I didn't change would probably always be there and could be used as 'Anchor' with 'Relative Positioning' for the 'P' Element to give:

Code: Select all

TAG POS=1 TYPE=SPAN ATTR=TXT:Today's<SP>featured<SP>article<SP>Der<SP>heute<SP>vorgestell*
TAG POS=R1 TYPE=P ATTR=TXT:* EXTRACT=TXT
(... => With "POS=R1" this time..., and the "R" stands for "Relative", but this Syntax always needs an 'Anchor' to know from which HTML Element the 2nd 'TAG' is relative...)

And my "whole" Script was more meant as a "Proof of Concept" and Example to show you how it works a bit, and that you can modify as you like of course... :wink:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Post Reply