Skip to main content
Inspiring
November 15, 2018
Question

Open all links on a cfm page

  • November 15, 2018
  • 5 replies
  • 1340 views

I have a cfm page with 30-40 links on it. These links send emails with attachments to different clients

I need to un this page and all of these links via a scheduled event

Rather than creating 30-40 scheduled events to open each link and send the emails, is there a way to go to the page and have CF open all the links?

Link1
Link2
Link3
Link4
.
.
.

.

Link40

    This topic has been closed for replies.

    5 replies

    weezerboyAuthor
    Inspiring
    November 19, 2018

    I appreciate all of the input on this.

    Here is why I need to open the links individually as opposed to encapsulating the 30-40 pages script into 1 page.

    Each of the 40 pages has about 500+ lines of code that create PDF, do data merging and then sends large PDFs.
    Lots of server intensive stuff

    Some of the pages take 30-45 seconds to complete.

    So I really need to keep these separate and not put them into 1 page.

    I think I am going to look into something like this  ...<cfhttp url

    WolfShade
    Legend
    November 19, 2018

    If each page is not dependent upon a previous page being processed before it starts, you can CFINCLUDE each into a CFTHREAD and process them that way, on a single page.

    HTH,

    ^ _ ^

    weezerboyAuthor
    Inspiring
    November 19, 2018

    can you give an example of this Wolf?

    BKBK
    Community Expert
    Community Expert
    November 18, 2018

    weezerboy  wrote

    Rather than creating 30-40 scheduled events to open each link and send the emails, is there a way to go to the page and have CF open all the links?

    Link1
    Link2
    Link3
    Link4
    .
    .
    .

    .

    Link40

    Sure thing. Use

    <cfhttp url="linkX" >

    to open each link

    WolfShade
    Legend
    November 19, 2018

    Yeah, you _could_ use CFHTTP to grab the contents of a local .cfm page and parse it for links.. but, WHY?  This could be also done in AJaX with zero cost to the webserver or the CF server.  Let the client do the work.

    But, again, WHY?  Create a page with no concern about UX/UI, put it in Scheduled Tasks, done.

    Just my two cents.

    V/r,

    ^ _ ^

    Charlie Arehart
    Community Expert
    Community Expert
    November 19, 2018

    Wolf, you ask why one would go the other route and not edit the page creating the links to be more dynamic and then use a variant of the page without ui to call the links.

    Only Weezer can tell us what's possiblr for him, but since I offered on of the alternatives (and therefore your question may be to me as well), I'll just propose that someone in his shoes may not be free to edit the page in question.

    And one may assert then that he just extract the url's into a template (or db) to then call them WITHOUT scanning the page that offers them.. But it is possible that the page and links change.

    So I simply offered the option if either may be the case. As I said at the open of my first comment, you and others are indeed right to press if there may be a better way.

    I just offered an option if those don't work for him, and in case someone else reading this in the future may need it, perhaps for a page of links that may even not be on their server, or not a CF page they control, etc.

    /Charlie (troubleshooter, carehart. org)
    Charlie Arehart
    Community Expert
    Community Expert
    November 16, 2018

    And though others are rightly focused on other solutions, it's worth noting that on the surface, no, there is no feature in CF that would read a page and run the links on that page.

    That concept is typical of "spiders" (or crawlers), such as are used by search engines (to trawl through all pages on a site, which then find and follow links in each page, saving all the content and links to run again the next day, to keep track of content on sites that are to be searched).

    There's no feature in CF to spider a site, let alone a page. Some may want to note that since CF includes Solr, which is based on Lucene, there is indeed a lucene-based crawler called Nutch (http://nutch.apache.org​​). But there is no specific integration of CF with that.

    And while I'm not aware of any other sort of feature or tool within CF that could easily do the sort of scanning of a page to find links that you seek, I will note that there is a a free online tool that does purport to find links on a page and return them as a simple text list. Try this link:

    https://api.hackertarget.com/pagelinks/?q=learncfinaweek.com


    And you could call that with CFHTTP then loop over the result doing other cfhttp calls to get whatever they offer. Note that you are limited to running 100 such requests to the api per day (unless you pay for more).

    That said, it seems to be looking for only certain kinds of links (like a href references) and not others that would seem to us to be links (perhaps javascript-based), because if you point the tool to the Adobe forums (which has many links, of course), it returns none:

    https://api.hackertarget.com/pagelinks/?q=forums.adobe.com

    There are still some other things about the tool (it doesn't follow redirects, etc.) that you can read about here:

    https://hackertarget.com/extract-links/ 

    Hope that's of some help, to you or other readers who may find this discussion.

    /Charlie (troubleshooter, carehart. org)
    WolfShade
    Legend
    November 16, 2018

    It _CAN_ be done, but as Eddie has pointed out, it's not the best approach.

    Create a template, don't bother with UX/UI since no user will actually see it (you can even set it so that if the user-agent does not include CFSCHEDULER, it won't run), put all the logic in place to generate PDFs, etc., and set it up in Scheduled Tasks.  BAM, done.

    V/r,

    ^ _ ^

    EddieLotter
    Inspiring
    November 15, 2018

    Why bother "opening" the links? You have the logic that created the links. Use the same logic to send the e-mails in your scheduled task.

    weezerboyAuthor
    Inspiring
    November 15, 2018

    Its not just sending emails but a lot of other logic, like creating PDFS etc - seems like too much

    EddieLotter
    Inspiring
    November 15, 2018

    Then you need to encapsulate the logic so that there is no duplication and it can be called from a link or from a scheduled task.