• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Parsing HTML returned from CFHTTP

Contributor ,
Dec 19, 2008 Dec 19, 2008

Copy link to clipboard

Copied

I am trying to create a function that will parse out individual pieces of information returned by a cfhttp request. I need the name of the city, country, and state returned. I need the script to start at the word " CITY: ", " STATE: ", and " COUNTRY: " respectively and ends at <br>. I know I can use findNoCase to locate the start point, but how can I say 'get until you reach the next <br>' ?

Here is my returned data (I bolded what I need returned):
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <HTML><HEAD><TITLE>Geo Results</TITLE> </HEAD><BODY> VERSION=1.0<br> <p> TARGET: 172.20.85.84<br> NAME: IANA-BBLK-RESERVED1<br> NUMBER: 172.16.0.0 - 172.31.255.255<br> CITY: AMSTERDAM<br> STATE: NORTH HOLLAND (province) <br> COUNTRY: NL<br> LAT: 52.35<br> LONG: 4.90<br> LAT_LONG_GRAN: City<br> LAST_UPDATED: <br> NIC: RIPE<br> LOOKUP_TYPE: Block Allocation<br> RATING: <br> DOMAIN_GUESS: ripe.net<br> STATUS: OK<br> </BODY></HTML>
TOPICS
Advanced techniques

Views

674

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 19, 2008 Dec 19, 2008

Copy link to clipboard

Copied


This would probably be betters served by reFindNoCase() rather then the
simplier findNoCase(). The former allows you to use regular expressions
to find more complex strings. Something like
"refindnocase("CITY:.*[^<]<br>",cfhttp.FileContent)" should be close to
what you are looking for, but I am not supper efficient at regular
expression code and this is untested and untried.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 20, 2008 Dec 20, 2008

Copy link to clipboard

Copied

Seems like its on the right path, but I get: 242

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2008 Dec 21, 2008

Copy link to clipboard

Copied

Seems like its on the right path, but I get: 242

The position in the string.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2008 Dec 21, 2008

Copy link to clipboard

Copied

You can do it in Coldfusion 8 using the reMatch or reMatchNoCase function, as follows:


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 21, 2008 Dec 21, 2008

Copy link to clipboard

Copied

That would be awesome. I am sorry, I should have mentioned that I am working on Blue Dragon at the U. That code will come in handy on another project though!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2008 Dec 21, 2008

Copy link to clipboard

Copied

LATEST
I am working on Blue Dragon at the U.

Never mind. Nobody's perfect.;)
The following should do.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation