<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Francesco Orsi</title>
    <description>The latest articles on DEV Community by Francesco Orsi (@orsifrancesco).</description>
    <link>https://dev.to/orsifrancesco</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F756591%2F792c2bb6-48da-4c5a-b159-8c7b294486c0.jpeg</url>
      <title>DEV Community: Francesco Orsi</title>
      <link>https://dev.to/orsifrancesco</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/orsifrancesco"/>
    <language>en</language>
    <item>
      <title>Saving Instagram images automatically every hour with Node.js or PHP</title>
      <dc:creator>Francesco Orsi</dc:creator>
      <pubDate>Thu, 20 Apr 2023 21:24:48 +0000</pubDate>
      <link>https://dev.to/orsifrancesco/saving-instagram-images-automatically-every-hour-with-nodejs-or-php-3ppe</link>
      <guid>https://dev.to/orsifrancesco/saving-instagram-images-automatically-every-hour-with-nodejs-or-php-3ppe</guid>
      <description>&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Just a &lt;strong&gt;web space&lt;/strong&gt; where to execute a Node.js script.. or PHP script; alternatively you can run the script on your computer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;If you want to run the script automatically you need&lt;/em&gt; &lt;strong&gt;Crontab installed&lt;/strong&gt; where you execute the code &lt;strong&gt;or a free account to &lt;a href="https://crontaboo.com/"&gt;crontaboo.com&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Simple way to do it
&lt;/h2&gt;

&lt;h4&gt;
  
  
  1 - Go to &lt;a href="https://github.com/orsifrancesco/sniffagrammers"&gt;https://github.com/orsifrancesco/sniffagrammers&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Download the repo. From this moment you decide which language you want to use (Node.js or PHP), the scripts are pretty similar.&lt;/p&gt;

&lt;h4&gt;
  
  
  2 - Open &lt;code&gt;node/sniffagrammer.js&lt;/code&gt; or &lt;code&gt;php/sniffagrammer.php&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Edit the code according to your needs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// type can be 'tag' or 'user'&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;// if type is 'tag', the script will search for #orsifrancesco&lt;/span&gt;
&lt;span class="c1"&gt;// if type is 'user', the script will search for @orsifrancesco&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;orsifrancesco&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;// only for sniffagrammer.js&lt;/span&gt;
&lt;span class="c1"&gt;// you can change the port of the server&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3 - Upload the script on your web space.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;If you use Node.js just run &lt;code&gt;node sniffagrammer.js&lt;/code&gt; (and open the browser).&lt;/li&gt;
&lt;li&gt;If you use PHP you can just upload &lt;code&gt;sniffagrammer.php&lt;/code&gt; to your web space.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  4 - Open the browser
&lt;/h4&gt;

&lt;p&gt;You should be able to see the output on &lt;code&gt;http://yourWebSpace:8080&lt;/code&gt; (or the port you set, or &lt;code&gt;http://localhost:8080&lt;/code&gt; if you are running the Node.js script on your computer) or &lt;code&gt;http://yourWebSpace/sniffagrammer.php&lt;/code&gt; (or &lt;code&gt;http://localhost&lt;/code&gt; if you are running the PHP script on the &lt;code&gt;htdocs/&lt;/code&gt; folder of your computer).&lt;/p&gt;

&lt;p&gt;Every time you open the URL, the script will call &lt;a href="https://orsi.me/sniffagram/"&gt;Sniffagram&lt;/a&gt; endpoint checking for new images and saving them on &lt;code&gt;images/&lt;/code&gt; folder.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NMEQHx4v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxm0we5rpaz75bqtfgzh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NMEQHx4v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxm0we5rpaz75bqtfgzh.png" alt="JSON output" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  5 - Check the result
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;On &lt;code&gt;images/{type}/&lt;/code&gt; (where &lt;em&gt;type&lt;/em&gt; can be &lt;code&gt;tag&lt;/code&gt; or &lt;code&gt;user&lt;/code&gt;) you will see all the downloaded images.&lt;/li&gt;
&lt;li&gt;Every time you download a new image, you will find the hash (&lt;a href="https://en.wikipedia.org/wiki/Hash_function"&gt;wikipedia&lt;/a&gt;) of the image path on &lt;code&gt;temp/{type}/&lt;/code&gt;. These files are 0 bytes, they are necessary to prevent downloading the same images (&lt;em&gt;if you delete these files the images will be downloaded again&lt;/em&gt;).
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0bm7oQtZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/swyuwdylj66wtkz8zn72.png" alt="folders" width="800" height="359"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  6 - Download images automatically every hour
&lt;/h4&gt;

&lt;p&gt;To call the URL automatically, you need to run a crontab (&lt;a href="https://en.wikipedia.org/wiki/Cron"&gt;wikipedia&lt;/a&gt;) script. If you don't have crontab installed on your machine you can register at &lt;a href="https://crontaboo.com/"&gt;crontaboo.com&lt;/a&gt; (&lt;em&gt;the free account gives you the possibility to call URLs every hour&lt;/em&gt;).&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G0QctsbV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4yz5jnwk003fpcehif2g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G0QctsbV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4yz5jnwk003fpcehif2g.png" alt="crontaboo.com" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Advanced way to do it
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5_gYCOjO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://user-images.githubusercontent.com/6490641/232155875-ce2ea2ec-eeb5-4bcc-9af7-8c8d82887420.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5_gYCOjO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://user-images.githubusercontent.com/6490641/232155875-ce2ea2ec-eeb5-4bcc-9af7-8c8d82887420.svg" width="800" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://orsi.me/sniffagram/"&gt;Sniffagram&lt;/a&gt; is an independent project that gives you 30 calls a day (&lt;em&gt;enough for a call every hour&lt;/em&gt;). It caches the output for 5 minutes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Due to the high number of requests, sometimes the token used for the project expires prematurely making the service unavailable (usually the expired token is replaced after a few minutes).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For unlimited requests (no cache, every minute) you need to follow the tutorial from the official repo &lt;a href="https://orsi.me/instagram-without-api/"&gt;Instagram without API&lt;/a&gt; for &lt;a href="https://github.com/orsifrancesco/instagram-without-api-node"&gt;Node.js&lt;/a&gt; or &lt;a href="https://github.com/orsifrancesco/instagram-without-api"&gt;PHP&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Resource Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://orsi.me/sniffagram/"&gt;Sniffagram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/orsifrancesco/sniffagrammers"&gt;GitHub Sniffagrammers&lt;/a&gt; scripts for Node.js and PHP&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://crontaboo.com/"&gt;Crontaboo&lt;/a&gt;, simple way to call URLs without crontab&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/orsifrancesco/instagram-without-api-node"&gt;Instagram without API&lt;/a&gt; Node.js&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.npmjs.com/package/instagram-without-api-node"&gt;Instagram without API&lt;/a&gt; npm&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/orsifrancesco/instagram-without-api"&gt;Instagram without API&lt;/a&gt; PHP&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://orsi.me/instagram-without-api/"&gt;Instagram without API&lt;/a&gt; tutorial&lt;/li&gt;
&lt;li&gt;Any feedback to &lt;a href="https://twitter.com/orsifrancesco" rel="nofollow"&gt;@orsifrancesco&lt;/a&gt; and &lt;a href="https://www.paypal.com/donate/?business=5EL4L2LDYVH96" rel="nofollow"&gt;coffees&lt;/a&gt; are welcome :)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>php</category>
      <category>instagram</category>
    </item>
  </channel>
</rss>
