# Mining information from PDF URLs using regex

**URL:** https://forum.openrefine.org/t/mining-information-from-pdf-urls-using-regex/278
**Category:** Support and Helpdesk
**Created:** [December 19, 2022, 3:05am UTC](https://forum.openrefine.org/t/mining-information-from-pdf-urls-using-regex/278 "2022-12-19T03:05:53Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![Chris\_Erdmann](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/chris_erdmann/32/45_2.png) [@Chris\_Erdmann](https://forum.openrefine.org/u/Chris_Erdmann)
#### Post date: [December 19, 2022, 3:05am UTC](https://forum.openrefine.org/t/mining-information-from-pdf-urls-using-regex/278/1 "2022-12-19T03:05:53Z")

</div>

I'm trying to use a Python script in OpenRefine via Edit Column \> Add column based on this column (Jython/Python)... where the column has links to PDFs. The script I have is:

import pdftotext  
from urllib.request import urlopen

target\_url = value  
file = urlopen(target\_url)  
pdf = pdftotext.PDF(file)

# Match the regular expression against the contents of the PDF file

pattern = '\d\d.\d+/\S\*'  
matches = re.findall(pattern, "\n\n".join(pdf))  
output = ';'.join(matches)  
return output

Here is an example:  
PDF link [https://jnnp.bmj.com/content/jnnp/91/8/795.full.pdf](https://jnnp.bmj.com/content/jnnp/91/8/795.full.pdf)

Any ideas on what I need to correct for this script to work? Or maybe there is a more efficient way to open a PDF URL and match patterns for inclusion in my OpenRefine project? Thanks!

---

_[View the full topic](https://forum.openrefine.org/t/mining-information-from-pdf-urls-using-regex/278)._
