I have a point feature class in a personal geodatabase. I would like to select a group of points and open all the hyperlinked pdf documents in the group, or even export all the hyperlinked pdfs somewhere. Any ideas?
You can create a list of the URL's and then use the code below to download them:
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">main</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">import</SPAN> os folder <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'C:\GeoNet\DownloadPDFs'</SPAN> <SPAN class="comment token"># loop through selected hyperlinks and create the list of PDF urls</SPAN> lst <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.esri.com%2Ftraining%2Fassets%2Fdownloads%2Fesri-course-catalog.pdf" target="_blank">http://www.esri.com/training/assets/downloads/esri-course-catalog.pdf</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.esri.com%2Flibrary%2Fbrochures%2Fpdfs%2Farcgis-desktop.pdf" target="_blank">http://www.esri.com/library/brochures/pdfs/arcgis-desktop.pdf</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.esri.com%2Flibrary%2Fbrochures%2Fpdfs%2Farcgisextbro.pdf" target="_blank">http://www.esri.com/library/brochures/pdfs/arcgisextbro.pdf</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.esri.com%2Flibrary%2Fbrochures%2Fpdfs%2Farcgis-for-mobile.pdf" target="_blank">http://www.esri.com/library/brochures/pdfs/arcgis-for-mobile.pdf</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.esri.com%2Flibrary%2Fbrochures%2Fpdfs%2Farcgis-online.pdf" target="_blank">http://www.esri.com/library/brochures/pdfs/arcgis-online.pdf</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token"># process pdfs</SPAN> <SPAN class="keyword token">for</SPAN> pdf_url <SPAN class="keyword token">in</SPAN> lst<SPAN class="punctuation token">:</SPAN> pdf_out <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN>pdf_url<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>pdf_out<SPAN class="punctuation token">)</SPAN> download_file<SPAN class="punctuation token">(</SPAN>pdf_url<SPAN class="punctuation token">,</SPAN> pdf_out<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">def</SPAN> <SPAN class="token function">download_file</SPAN><SPAN class="punctuation token">(</SPAN>download_url<SPAN class="punctuation token">,</SPAN> output_pdf<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="comment token"><SPAN># </SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F24844729%2Fdownload-pdf-using-urllib" target="_blank">https://stackoverflow.com/questions/24844729/download-pdf-using-urllib</A></SPAN> response <SPAN class="operator token">=</SPAN> urllib2<SPAN class="punctuation token">.</SPAN>urlopen<SPAN class="punctuation token">(</SPAN>download_url<SPAN class="punctuation token">)</SPAN> file <SPAN class="operator token">=</SPAN> open<SPAN class="punctuation token">(</SPAN>output_pdf<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'wb'</SPAN><SPAN class="punctuation token">)</SPAN> file<SPAN class="punctuation token">.</SPAN>write<SPAN class="punctuation token">(</SPAN>response<SPAN class="punctuation token">.</SPAN>read<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> file<SPAN class="punctuation token">.</SPAN>close<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> __name__ <SPAN class="operator token">==</SPAN> <SPAN class="string token">'__main__'</SPAN><SPAN class="punctuation token">:</SPAN> main<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.