Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: imdbMoviesCSV Arguments: Description: Export movies in theaters as a CSV Page type: webl Render function: Module: global Page source: var getItem = fun(P, d, elem, class) var res = Elem(P, elem) inside d; if (class != nil) then every r in res do var c = r.class ? nil; if c == class then return r end end end; return res end; var clean = fun(item) if item != nil then return Str_Trim(Text(item)) else return "" end end; var P = GetURL("https://www.imdb.com/showtimes/location"); // div class="lister-item-content var res = "title\treleaseDate\truntime\tgenre\tdirector\tstar\tdescription\n"; every d in Elem(P, "div") do var c = d.class ? nil; if c == "lister-item-content" then var line = ""; var ok = true; var t = getItem(P, d, "h3", "list-item-header"); if Size(t) > 0 then var lines = Str_Split(Str_Trim(Text(t[0])), "\n"); line = line + Str_Trim(lines[0]); // title var dt = Str_Search(lines[1], `\d\d\d\d`); line = line + "\t" + dt[0][0]; // releaseDate var r = getItem(P, d, "span", "runtime"); line = line + "\t" + + Str_Split(clean(r), " ")[0]; // runtime r = getItem(P, d, "span", "genre"); line = line + "\t" + clean(r); // genre r = Elem(P, "p") contain Pat(P, "Director:") inside d; if Size(r) == 0 then r = Elem(P, "p") contain Pat(P, "Directors:") inside d; end; if Size(r) > 0 then var star = Pat(P, `Star:`) inside d; if Size(star) == 0 then star = Pat(P, `Stars:`) inside d; end; var a = Elem(P, "a") inside r[0] before star[0]; // Directors if Size(a) > 0 then line = line + "\t"; every director in a do line = line + clean(director) + ", " end; line = Select(line, 0, Size(line)-2) end; a = Elem(P, "a") inside r[0] after star[0]; // Stars if Size(a) > 0 then line = line + "\t"; every star in a do line = line + clean(star) + ", " end; line = Select(line, 0, Size(line)-2) end; a = Elem(P, "p") directlybefore r[0]; if Size(a) > 0 then line = line + "\t" + clean(a[0]) // description end; else ok = false end; if (ok) then res = res + line + "\n" end end end end; res; /* <div class="lister-item-content"> <div class="triangle"> </div> <h3 class="lister-item-header"> <a href="https://www.imdb.com/showtimes/title/tt6448152/"> Walking with Dinosaurs: Prehistoric Planet </a> <span class="lister-item-year text-muted unbold"> (2014) </span> </h3> <p class="text-muted text-small"> <span class="runtime"> 40 min </span> <span class="ghost"> | </span> <span class="genre"> Documentary, Animation </span> </p> <div class="ratings-bar"> <div class="inline-block ratings-user-rating"> <span class="userRatingValue" id="urv_tt6448152" data-tconst="tt6448152"> <span class="global-sprite rating-star no-rating"> </span> <span name="ur" data-value="0" class="rate" data-no-rating="Rate this"> Rate this </span> </span> <div class="starBarWidget" id="sb_tt6448152"> <div class="rating rating-list" data-starbar-class="rating-list" data-auth data-user id="tt6448152|imdb|0|0||||" data-ga-identifier title="Awaiting enough ratings - click stars to rate" itemtype="http://schema.org/AggregateRating" itemscope itemprop="aggregateRating"> <meta itemprop="ratingValue" content="0"> <meta itemprop="bestRating" content="10"> <meta itemprop="ratingCount" content="0"> <span class="rating-bg"> </span> <span class="rating-imdb " style="width: 0px"> </span> <span class="rating-stars"> <a href="https://www.imdb.com/register/login?why=vote" rel="nofollow" title="Register or login to rate this title"> <span> 1 </span> </a> <a href="https://www.imdb.com/register/login?why=vote" rel="nofollow" title="Register or login to rate this title"> <span> 2 </span> </a> <a href="https://www.imdb.com/register/login?why=vote" rel="nofollow" title="Register or login to rate this title"> <span> 3 </span> </a> <a href="https://www.imdb.com/register/login?why=vote" rel="nofollow" title="Register or login to rate this title"> <span> 4 </span> </a> <a href="https://www.imdb.com/register/login?why=vote" rel="nofollow" title="Register or login to rate this title"> <span> 5 </span> </a> <a href="https://www.imdb.com/register/login?why=vote" rel="nofollow" title="Register or login to rate this title"> <span> 6 </span> </a> <a href="https://www.imdb.com/register/login?why=vote" rel="nofollow" title="Register or login to rate this title"> <span> 7 </span> </a> <a href="https://www.imdb.com/register/login?why=vote" rel="nofollow" title="Register or login to rate this title"> <span> 8 </span> </a> <a href="https://www.imdb.com/register/login?why=vote" rel="nofollow" title="Register or login to rate this title"> <span> 9 </span> </a> <a href="https://www.imdb.com/register/login?why=vote" rel="nofollow" title="Register or login to rate this title"> <span> 10 </span> </a> </span> <span class="rating-rating "> <span class="value"> - </span> <span class="grey"> / </span> <span class="grey"> 10 </span> </span> <span class="rating-cancel "> <a href="https://www.imdb.com/title/tt6448152/vote?v=X;k=" title="Delete" rel="nofollow"> <span> X </span> </a> </span> </div> </div> </div> </div> <p class> A group of young pachyrhinosaurs face the trials of growing up in a prehistoric world. </p> <p class="text-muted text-small"> Director: <a href="https://www.imdb.com/name/nm0197773/"> Richard Dale </a> <span class="ghost"> | </span> Star: <a href="https://www.imdb.com/name/nm1212722/"> Benedict Cumberbatch </a> </p> </div> */