- Регистрация
- 25.09.2012
- Сообщения
- 12
- Благодарностей
- 0
- Баллы
- 0
I have some profilepages i want to scrape. But how the tables look like depends on what information there is on the profilepage. So if i just scrape everything, the output from the scraping will be written in different columns every time. If regex find the text "Phone", I need to write "12345" in column 1. But if Phone is missing, I need to it to just write "0".
</tr>
<tr>
<td>Phone</td>
<td>12345</td>
</tr>
<tr>
<td>Name</td>
<td>ABCDE</td>
</tr>
But if Phone is missing, it looks like this:
<tr>
<td>Name</td>
<td>ABCDE</td>
</tr>
I then need "0" in column 1 and then "ABCDE" in column 2. Since all the results I want is between <td> and </td>, I need to decide what result it is based on if the results before is Phone or Name. Is there a way to do this: "If Name is found, scrape the next result that is inside <td> and </td>"
I didnt make the scraping for column 2 to make it simple
</tr>
<tr>
<td>Phone</td>
<td>12345</td>
</tr>
<tr>
<td>Name</td>
<td>ABCDE</td>
</tr>
But if Phone is missing, it looks like this:
<tr>
<td>Name</td>
<td>ABCDE</td>
</tr>
I then need "0" in column 1 and then "ABCDE" in column 2. Since all the results I want is between <td> and </td>, I need to decide what result it is based on if the results before is Phone or Name. Is there a way to do this: "If Name is found, scrape the next result that is inside <td> and </td>"

I didnt make the scraping for column 2 to make it simple