I have a ruby script I have been working on that scrapes the source of a webpage and writes to file. I then have to read this file and pull out just specific data from this junk text file of data. I am able to do it in python and get the array I need. I would like to be able to just make my ruby code sleep for a min and do the same thing so I don't have to call the python script and then read the results back into ruby script to continue. I'm sure there is a way to do this in ruby I'm just starting out with ruby and not very savvy yet.
#!/usr/bin/env python
import re
f = open("C:/Users/Steve/Desktop/scripts/testout.txt", encoding="utf8")
da = f.read()
f.close()
matches = re.findall('href="/normal/PropertyDetails.rb.PID=(\d+)', str(da))
res = []
for i in matches:
if i not in res:
res.append(i)
print(str(res))
If I have to go the route with the python I will just have to sleep and call the python script write to another text file and then have ruby open the file read and continue. Just trying to make it as most efficient as I can.
After working with the suggestion below I was able to locate the correct resources to guide me further. Here is the ruby simplified code
data = driver.page_source
res = data.scan(/.PID=(\d+)/)
print(res.uniq)
now having that I can continue on with the ruby code I am learning with along the way. I think I have the other areas covered thanks for the assist.