1.获取github的ip
import socket from urllib.parse import urlparse # 通过URL获取目标服务器IP和端口号 def get_server_ip_and_port(url): # 解析URL获取域名和端口号 parsed_url = urlparse(url) domain = parsed_url.netloc port = parsed_url.port or 80 try: # 进行域名解析,获取目标服务器IP ip = socket.gethostbyname(domain) return ip, port except socket.error: return None, None # 主函数 def main(): url = "https://github.com" # 修改为目标URL ip, port = get_server_ip_and_port(url) if ip and port: print("目标服务器IP地址:", ip) print("目标服务器端口号:", port) else: print("无法获取目标服务器IP和端口号") if __name__ == "__main__": main()
2.点击pycharm的setting-Github Copilot,点击Manage HTTP proxy settings,手动设置代理
把第一步获取的IP填入主机名,保存后重启pycharm