N
N
NO1nam2020-04-22 20:19:15
Python
NO1nam, 2020-04-22 20:19:15

How to parse an ID?

my code

html_text = requests.get(url, cookies=cookies)
  soup = BeautifulSoup(html_text.text, 'html.parser')
  aue = soup.find('table',{'class':'cntr wa mlra'})
  idnick = aue.find_all('a')
  for name in idnick:
    nick = name.text
    print(nick)
    mrush.write(nick+'\n')
  mrush.close()

I now have to parse all nicknames and I need to get their ID
<table class="cntr wa mlra">
    <tbody><tr>
      <td class="p5">Место</td>
      <td class="p5">Имя</td>
              <td class="p5">Рейтинг</td>
          </tr>

              <tr>
          <td class="yell">1</td>
          <td class="">
                                          <a href="/view_profile?player_id=4310386" class="lwhite">Sherman</a>
                    </td>
          <td class="yell">67881</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">2</td>
          <td class="">
                                          <a href="/view_profile?player_id=2952751" class="lwhite">Astаrta</a>
                    </td>
          <td class="yell">66575</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">3</td>
          <td class="">
                                          <a href="/view_profile?player_id=8233419" class="lwhite">killernik</a>
                    </td>
          <td class="yell">66279</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">4</td>
          <td class="">
                                          <a href="/view_profile?player_id=7216037" class="lwhite">Мaркизa</a>
                    </td>
          <td class="yell">66032</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">5</td>
          <td class="">
                                          <a href="/view_profile?player_id=7940254" class="lwhite">Whitе Eagle</a>
                    </td>
          <td class="yell">64719</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">6</td>
          <td class="">
                                          <a href="/view_profile?player_id=2471064" class="lwhite">Лисёнок Ди</a>
                    </td>
          <td class="yell">64645</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">7</td>
          <td class="">
                                          <a href="/view_profile?player_id=2741792" class="lwhite">Юля лучшая</a>
                    </td>
          <td class="yell">64450</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">8</td>
          <td class="">
                                          <a href="/view_profile?player_id=5043654" class="lwhite">НЕЗЕРИЛ</a>
                    </td>
          <td class="yell">64248</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">9</td>
          <td class="">
                                          <a href="/view_profile?player_id=1963843" class="lwhite">ЗЕВС ЖЕКА</a>
                    </td>
          <td class="yell">63927</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">10</td>
          <td class="">
                                          <a href="/view_profile?player_id=5773233" class="lwhite">ЗагорскиЙ</a>
                    </td>
          <td class="yell">63784</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">11</td>
          <td class="">
                                          <a href="/view_profile?player_id=3571824" class="lwhite">СПАРТАНЕЦ АА</a>
                    </td>
          <td class="yell">63756</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">12</td>
          <td class="">
                                          <a href="/view_profile?player_id=10574962" class="lwhite">DT X</a>
                    </td>
          <td class="yell">63653</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">13</td>
          <td class="">
                                          <a href="/view_profile?player_id=949862" class="lwhite">Голд Лис</a>
                    </td>
          <td class="yell">63634</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">14</td>
          <td class="">
                                          <a href="/view_profile?player_id=3334852" class="lwhite">КрошкаРy</a>
                    </td>
          <td class="yell">63591</td>
        </tr><tr>
              </tr><tr>
          <td class="yell">15</td>
          <td class="">
                                          <a href="/view_profile?player_id=4585462" class="lwhite">verdikt</a>
                    </td>
          <td class="yell">63504</td>
        </tr><tr>
      
              </tr><tr>
          <td class="yell">10000</td>
          <td class="">
                                                  <a href="/view_profile?player_id=9168277" class="lyell">Романычь</a>
                      </td>
          <td class="yell">
            10162					</td>
        </tr><tr>
          </tr></tbody></table>

i need to get all player_id=

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-04-22
@NO1nam

Alternatively, replace the line:
nick = name.text
with:
nick = name.get('href').split('=')[1]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question