+ Reply to Thread
Results 1 to 9 of 9

Extract text from html code

  1. #1
    Registered User
    Join Date
    09-03-2015
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    mac osx
    Posts
    5

    Extract text from html code

    I have downloaded the source code of a web page from which i would like to extract some lines of text. The lines of text that I need always appear between to very identifiable lines of text. Let's call them A and B. The target text is not uniform in length. When I put the HTML on Excel, it comes out in a single column with rows nice and neat for each line of code. So I need some formula(e) that will search all of column B for instances of Text A and B and then return to me (preferrably in a single column) ONLY the text that appears between each instance of Text A and Text B.

    I hope this makes sense and someone can give me a clue how to do this easily.
    regards

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,372

    Re: Extract text from html code

    Can you post a sample file please.

    Click "Go Advanced" then Paper Clip icon to upload a file.

  3. #3
    Registered User
    Join Date
    09-03-2015
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    mac osx
    Posts
    5

    Re: Extract text from html code

    I think I've got it.
    Attached Files Attached Files

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Extract text from html code

    OK, so that is what you have - what do you want?
    The lines of text that I need always appear between to very identifiable lines of text. Let's call them A and B.
    No, lets not. Tell us exactly what you want
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    09-03-2015
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    mac osx
    Posts
    5

    Re: Extract text from html code

    between any line that follows

    <div class="definition-text">

    And comes before:

    <span class="word-is-mine-placeholder">

    This is a definition text for a word that is in a line above it. I just need to extract the definitions from this page (and several others like it.0

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Extract text from html code

    I am still unclear as to what a sample answer would look like, but lets see if this will get you headed in the right direction.

    I put your search criteris in their own cells (the " messed up hard-coding the test)
    E1<div class="definition-text">
    E2<span class="word-is-mine-placeholder">

    Then I used this in C1 to ID your 1st criteria...
    =IF(ISNUMBER(SEARCH($E$1,A1,1)),A1,"")
    and this in D1 to ID and extract your 2nd criteria
    D1=IF(ISNUMBER(SEARCH($E$2,A1,1)),LEFT(A1,SEARCH($E$2,A1,1)-1),"")
    both copied down

    If you scroll down to row453, you will see an entry in C453 and in D454

    let me know what you need to do next?

  7. #7
    Registered User
    Join Date
    09-03-2015
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    mac osx
    Posts
    5

    Re: Extract text from html code

    If you can take a look at the web page, you'll see a series of words, definitions, and sentences. I'd like to have the definitions in order they appear in the document (kind of like the web page). I actually would love to find some way to make the table that is in the web page appear in excel but it won't copy/paste so i'm looking for other options. There are a few dozen word groups i need to do this for and i'm looking for a fast way to do it without having to type each word/sentence/definition/etc. I figured there might be some magic excel formula that would at least give me the definitions in a column so i can cut/paste them next to the word list.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Extract text from html code

    So show me what you want?

  9. #9
    Registered User
    Join Date
    09-03-2015
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    mac osx
    Posts
    5

    Re: Extract text from html code

    will have to take another approach as the deadline is upon me. Thank you for the help anyway. Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to extract & save all text with similar html tags - imacros
    By faizzsheikh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2015, 04:18 AM
  2. VBA to open saved web html pages - extract text - paste text within individual cell
    By EddieRubi in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-23-2015, 01:43 PM
  3. VBA to Extract Data from HTML Code
    By Juggler_IN in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2014, 12:44 PM
  4. Search HTML source code for text
    By davegugg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-23-2009, 10:54 AM
  5. extract text from html files
    By Glowinafuse in forum Excel General
    Replies: 0
    Last Post: 05-31-2005, 03:05 AM
  6. [SOLVED] extract text from html files
    By Glowinafuse in forum Excel General
    Replies: 1
    Last Post: 05-27-2005, 03:22 PM
  7. [SOLVED] extract text from html files
    By Glowinafuse in forum Excel General
    Replies: 0
    Last Post: 05-26-2005, 09:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1