"""
-*- coding:utf-8 -*-
@Time   :2020/12/15 14:09
@Author : 【Python楚君】 
@File   :xingming_html.py
@Version:1.0
"""
import requests
 
if __name__ == '__main__':
    # 仅修改xing、gender即可(此例子表示:姓李的女孩姓名)
    xing = ['li', '李']  # 元素1:对应姓的拼音  元素2:姓
    gender = '女'
 
 
    # 以下不用修改
    index = 1
    print('【', xing[1], gender, '】')
    for i in range(100):
        if gender == '男':
            result = requests.get(
                'http://{}.resgain.net/name/{}_{}.html'.format(xing[0], 'boys', index))
            result = result.content.decode('utf-8')
            slp = '<meta name="description" content="{}姓{}孩名字大全,{}姓{}孩名,{}姓{}孩取名:'.format(xing[1], gender, xing[1],
                                                                                          gender, xing[1], gender)
            result = result.split(slp)[1]
            result = result.split('">')[0]
            print(result)
            index += 1
        if gender == '女':
            result = requests.get(
                'http://{}.resgain.net/name/{}_{}.html'.format(xing[0], 'girls', index))
            result = result.content.decode('utf-8')
            result = result.split(
                '<meta name="description" content="{}姓{}孩名字大全,{}姓{}孩名,{}姓{}孩取名:'.format(xing[1], gender, xing[1],
                                                                                        gender, xing[1], gender))[1]
            result = result.split('">')[0]
            print(result)
            index += 1