Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7878413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:39:07+00:00 2026-06-03T03:39:07+00:00

I’m trying to write a script to visit links for movies at boxofficemojo.com and

  • 0

I’m trying to write a script to visit links for movies at boxofficemojo.com and extract gross earnings for the specific movie. I’m writing these scripts as a Google Apps script because I want to plug it into a spreadsheet.

My original implementation worked well when it was just looking for the Domestic Total listed very prominently on the movie page. (http://boxofficemojo.com/movies/?id=clashofthetitans2.htm for example would extract the “$80,882,168” right below the “Domestic total as of [date]). I wanted to extend this script so that I would be able to get the Worldwide total gross listed under Total Lifetime Grosses, but I am unable to do so and I’m not sure why.

Here is the code in question:

function gross(aUrl)
{
  var page = UrlFetchApp.fetch(aUrl).getContentText();
  var matched = page.match(/Worldwide:<\/b><\/td>.*(\$.*)<td width="25%">/m);
  var amt = "$0";
  if (matched == null)
  {
    matched = page.match(/<b>(\$.*)<\/b>.*Distributor:/m);
    if (matched != null)
    {
      amt = matched[1];
    }

  } else
  {
    amt = matched[1];
  }
  return amt;
}

function testGross()
{
  var result = gross("http://boxofficemojo.com/movies/?id=clashofthetitans2.htm");
  Logger.log(result);
}

It should be worth nothing that the second regexp works fine but the first one doesn’t. The output of running testGross() would result in the following data in the Logs:

null
$80,882,168

I tested the regexp at http://www.rubular.com with the data that comes from just viewing the page source when I am at the movie page. I’m certain that the page being returned for matching hasn’t been truncated anymore because when I replace the page.match line with a line that sends an email to me with the full content of the page variable, I get a page identical to what I would get if I chose to view page source.

Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:39:09+00:00Added an answer on June 3, 2026 at 3:39 am

    By looking at the page source of the example you used, I can see that you forgot the “closing” part in the regex. Here is the relevant part:

    <td width="40%">=&nbsp;<b>Worldwide:</b></td>
    <td width="35%" align="right">&nbsp;<b>$289,732,168</b></td>
    <td width="25%">&nbsp;</td>
    

    In your regex, after the (\$.*) part, you don’t consider the </b></td> and space chars.
    Also, the m modifier does not work as you expect. Actually it does not make a difference here. The . will not match new lines. Here is your “fixed” regex:

    /Worldwide:<\/b><\/td>[\s\S]*(\$.*)<\/b>[\s\S]*<td width="25%">/m
    

    Anyway, here’s how I’d do it:

    /Worldwide:<\/b><\/td>[\s\S]*?<b>(\$.+)<\/b><\/td>/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I'm trying to select an H1 element which is the second-child in its group
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.