S
S
Sap sun2021-11-25 01:35:07
Python
Sap sun, 2021-11-25 01:35:07

Text editing. How to cut out the necessary fragments from an array of links?

There are a number of links to Facebook profiles, about 40,000.
They look something like this
https://www.facebook.com/profile.php?id=100056378844823
https://www.facebook.com/profile.php?id=100036605837335
https: //www.facebook.com/profile.php?id=100003312311771
You need to delete everything just so that the id remains. Something like this:
100056378844823
100036605837335
100003312311771
And to save it in txt or excel.
How can this procedure be implemented? excel, python, java
I would be very grateful for any information)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
goctio, 2021-11-25
@Sweet1488

Python:

With the help of .split we split the line, and we get the required number.
array = ['https://www.facebook.com/profile.php?id=100003312311771', 'https://www.facebook.com/profile.php?id=100036605837335']

for x in array:
  res = x.split('php?id=')[1]
  print(res)
  with open('some.txt', 'a') as save:
    save.write(res + '\n')

S
shellnet, 2021-11-25
@warlinx

import re
inp_str = " https://www.facebook.com/profile.php?id=100003312311771 "
print("Original string : " + inp_str)
num = re.findall(r'\d+', inp_str)
print(num )

A
Alexander Vasiliev, 2022-02-17
@amvasiljev

Good afternoon.
Text by columns - separator "="

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question