<?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: swkidd</title>
    <description>The latest articles on DEV Community by swkidd (@swkidd).</description>
    <link>https://dev.to/swkidd</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%2F378412%2F4b6a18d3-0c24-44f8-81bc-0bc8ba215d94.gif</url>
      <title>DEV Community: swkidd</title>
      <link>https://dev.to/swkidd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/swkidd"/>
    <language>en</language>
    <item>
      <title>Challenge: Find the least positive missing number</title>
      <dc:creator>swkidd</dc:creator>
      <pubDate>Thu, 21 May 2020 08:17:20 +0000</pubDate>
      <link>https://dev.to/swkidd/challenge-find-the-least-positive-missing-number-4hpd</link>
      <guid>https://dev.to/swkidd/challenge-find-the-least-positive-missing-number-4hpd</guid>
      <description>&lt;p&gt;Find the least positive number missing from a list in linear time with constant extra space &lt;/p&gt;

&lt;p&gt;ex:&lt;br&gt;&lt;br&gt;
&lt;code&gt;[1,2,3,4] -&amp;gt; 5&lt;/code&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;[-1,0,1] -&amp;gt; 2&lt;/code&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;[-20,3,10,1] -&amp;gt; 2&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;One solution uses linear time and linear extra space. Then there's an extra spicy solution that uses linear time and constant space.  &lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/swkidd/embed/BaoMapb?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>challenge</category>
    </item>
    <item>
      <title>Quick list / feed scraping in the dev console</title>
      <dc:creator>swkidd</dc:creator>
      <pubDate>Sun, 03 May 2020 05:01:27 +0000</pubDate>
      <link>https://dev.to/swkidd/quick-list-feed-scraping-in-the-dev-console-2ei1</link>
      <guid>https://dev.to/swkidd/quick-list-feed-scraping-in-the-dev-console-2ei1</guid>
      <description>&lt;p&gt;&lt;a href="https://i.giphy.com/media/WRdUx1XYa0i4UPxLxa/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/WRdUx1XYa0i4UPxLxa/giphy.gif" alt="Scraping list data in the dev console"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// function to create array of elements from an xpath&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;xeval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;each&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;iter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;XPathResult&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ANY_TYPE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;elems&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
  &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;iter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;iterateNext&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;elems&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;each&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;elems&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I was recently helping someone scrape app reviews and came across this tip. This will work to scrape any list / feed of elements.  &lt;/p&gt;
&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;A lot of sites generate class names on page load, so you can't always use class names / id's to pull page data. The solution is to use &lt;a href="https://developer.mozilla.org/en-US/docs/Web/XPath"&gt;XPATH&lt;/a&gt;. I was surprised by how easy this is!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Scroll down the page a bit and choose an element you want to scrape&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inspect the element and copy it's XPath&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;right click element in dev window -&amp;gt; copy -&amp;gt; XPath / full XPath&lt;/code&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;it will look like:&lt;br&gt;
&lt;code&gt;'.../div/div[10]/div/div[2]/div[1]/div[1]/span'&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;by deleting '[10]' all like elements will be selected &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;use the XPath to select the page elements&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's it! &lt;/p&gt;

&lt;p&gt;Here's the code  &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
