Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2014
    Posts
    4
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Post Big Cartel Order Extractor

    Hi, there's a site out there called Big Cartel that allows you to setup online stores. As orders come in, they are organized on an order page. You can then click each individual order and a new page pops up with the order details. From here you can print the order. I'd like to create a script that will extract the individual URL of each order on the page and then save it as a web doc or pdf so I can print them as a batch of orders. Do you think this is possible? The whole process doesn't have to be scripted, but maybe at least to the point of extracting each URL and downloading the link. I can do the batch printing by myself. The code in the HTML for the list of orders is as follows (of course with sample names):



    <ul id="orders_list" class="list_view">
    <li class="order item payment_paid shipped" id="order_5514565971"> <h4><a href="https://morethanconquerorsclothing.bigcartel.com/admin/orders/ZUVI-098198">John Smith</a></h4>
    <span class="time tooltip" title="12/13/2013 @ 9:43 PM">6 months ago</span>
    <span class="total">$5.00</span>
    <span class="status">Completed</span>
    <ul class="item_actions">
    <li><a href="/admin/orders/ZUVI-098198/toggle_shipping" class="shipping_toggle tooltip" title="Mark as unshipped">Toggle shipping</a></li>
    </ul>
    </li>

    <li class="order item payment_paid shipped" id="order_4917114660"> <h4><a href="https://morethanconquerorsclothing.bigcartel.com/admin/orders/GWLO-087680">James Smith</a></h4>
    <span class="time tooltip" title="10/17/2013 @ 12:20 PM">8 months ago</span>
    <span class="total">$40.00</span>
    <span class="status">Completed</span>
    <ul class="item_actions">
    <li><a href="/admin/orders/GWLO-087680/toggle_shipping" class="shipping_toggle tooltip" title="Mark as unshipped">Toggle shipping</a></li>
    </ul>
    </li>

    <li class="order item payment_paid shipped" id="order_4902411225"> <h4><a href="https://morethanconquerorsclothing.bigcartel.com/admin/orders/LNAT-761950">Josh Smith</a></h4>
    <span class="time tooltip" title="10/15/2013 @ 10:12 PM">8 months ago</span>
    <span class="total">$15.00</span>
    <span class="status">Completed</span>
    <ul class="item_actions">
    <li><a href="/admin/orders/LNAT-761950/toggle_shipping" class="shipping_toggle tooltip" title="Mark as unshipped">Toggle shipping</a></li>
    </ul>
    </li>
    </ul>


    Thanks for any feedback you have!

    Samuel

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,309
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    JavaScript running in the browser does not have any commands for reading or writing files. JavaScript is a client-side language; modern browsers can read files on the server using an Ajax call, but otherwise JavaScript has no capability to read from, write to or delete a file (except a cookie), communicate with the server, access a database, the client's operating system or the Windows registry, or alter the default behaviour of the browser. And for security reasons JavaScript cannot access anything beyond the domain of the current page. This is known as the "same origin policy" and prevents a document or script loaded from one origin from getting or setting properties of a document from a different origin.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    sdbernhardt (06-14-2014)

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,461
    Thanks
    11
    Thanked 600 Times in 580 Posts
    this assumes you're downloading the links in the H4, adjust as needed:

    Code:
    [].forEach.call(
     document.querySelectorAll("h4 a"),
     function(a){
        a.download=a.textContent.trim()+".html";
        a.click();
     });
    * Note that chrome v35 introduced a bug where the filename isn't respected. it's on the fix list, but you can use FireFox for now or wait 4 more weeks.
    Last edited by rnd me; 06-12-2014 at 09:54 PM.
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • Users who have thanked rnd me for this post:

    sdbernhardt (06-14-2014)


  •  

    Tags for this Thread

    Posting Permissions

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