Copy text in web pages?

Hello,

I need some help with copying or getting text on a webpage. Please see the pictures below.

Original Size (1) https://dl.dropboxusercontent.com/u/57960302/page_01.jpg
Original Size (2) https://dl.dropboxusercontent.com/u/57960302/page_02.jpg

The numbers are RANDOM. It's different for each ticket. And it doesn't have to copy the numbers if there's other way to set the URL.


I'm using JavaScript given by ccstone to read text on webpages.

Thanks,
K

Hey K,

Please provide as accurate a sample as possible of the text you're needing to parse (the output of your JavaScript).

-Chris

Hey Chris,

Okay. This is an actual screenshot of the webpage. link

Thanks a lot!
K

Hey K,

It's good to see that, but unfortunately it does NOT properly represent the format of the text returned by the JavaScript. That's why I want to see and test with a real sample.

-Chris

Okay, this is what I just got. It doesn’t contain the “Available…” text though.
SAMPLE https://dl.dropboxusercontent.com/u/57960302/20160515%20125600.rtf
SCREENSHOT https://dl.dropboxusercontent.com/u/57960302/2016-05-15%2012.57.22.png

Hey K,

Why not? That's what you need to parse – yes?

I need to see a complete sample to figure out how to parse it.

Change the numbers to all zeros if they're private.

-Chris

Hey Chris,

Yes, right. But the “Available…” part appears only a few times a day and each one lasts even less than 3 seconds so it’s very hard to get a sample of them. However, as you can see in this, I’m sure it doesn’t make a big difference. To consider “Reviewable…” in the sample as “Available…” is just fine. The number I always need is the first 8-digit number right after the first “Collection #”. In the sample, that is “16476965”.

Thank you very much for your time and kind help, as always.
K

Hey K,

Alright.

For future reference – you can probably save the page as html or as a .webarchive – then load the file and run a script on it.

You'll have to adjust this appropriately, but it should get you close.

-Chris

Generic-Test 01.kmmacros (3.1 KB)

1 Like

Hey Chris,

Wow, that is great! Now I'm trying to set Google Chrome URL to "http://aaaaa.bbb/ccc/d/jobNumber/" like below but it doesn't seem right. Would you please help me with this once again?

Thanks,
K

Hey K,

That looks about right.

Maybe you don't need the trailing “/”?

You don't need the BBEdit AppleScript of course. That was just a stand-in for the JavaScript.

-Chris

Hey Chris,

You were right. It works perfectly!
I want to learn the language(?) and do it by myself for the future, hopefully. What should I study specifically?

Again, thank you very, very much for your help!

Hey K,

Very good.

You mean the RegEx (regular expressions) – or the AppleScript – or both?

For RegEx see this topic on the Wiki:

Regular Expressions (RegEx)

For AppleScript take a peek at these:

References For Learning & Using Applescript.txt

Learning & Using AppleScript & JavaScript for Automation (JXA)

-Chris

1 Like